Last change
on this file since 51d3aa0 was
9b03842,
checked in by Ted Faber <faber@…>, 12 years ago
|
Fail on no routing
|
-
Property mode set to
100644
|
File size:
753 bytes
|
Rev | Line | |
---|
[e48d8eb] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use IO::File; |
---|
| 5 | |
---|
| 6 | my $IFCONFIG = "/sbin/ifconfig"; |
---|
| 7 | my $ROUTE = "/sbin/route"; |
---|
| 8 | my $IPROUTE = "/sbin/ip"; |
---|
| 9 | my $hostname = `hostname`; |
---|
| 10 | my $routefile = "/usr/local/federation/etc/route/"; |
---|
| 11 | |
---|
| 12 | $hostname =~ s/\..*//; |
---|
| 13 | $routefile = "$routefile$hostname"; |
---|
| 14 | |
---|
[9b03842] | 15 | my $f = new IO::File($routefile) || die "No routing file: $!\n"; |
---|
[e48d8eb] | 16 | while (<$f>) { |
---|
| 17 | chomp; |
---|
| 18 | my ($dest, $gw) = split; |
---|
| 19 | if (-x $IPROUTE ) { |
---|
| 20 | my $cmd = "$IPROUTE route add $dest via $gw"; |
---|
| 21 | print("$cmd\n"); |
---|
| 22 | system("$cmd"); |
---|
| 23 | } elsif (-x $ROUTE ) { |
---|
| 24 | system("$ROUTE add $dest $gw"); |
---|
| 25 | } else { |
---|
| 26 | warn "Cannot find a routing command!\n"; |
---|
| 27 | } |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | $f = new IO::File(">/proc/sys/net/ipv4/ip_forward") || |
---|
| 31 | die "Can't open sys forwarding file:$!\n"; |
---|
| 32 | print $f "1\n"; |
---|
| 33 | $f->close(); |
---|
| 34 | |
---|
Note: See
TracBrowser
for help on using the repository browser.