3 # ip-down -- executed by pppd on connection death
5 # This particular implementation of ip-down attempts to re-establish
6 # the ppp connection. It does this by first forking and having the
7 # parent die (returning control to the invoking pppd for final
10 # The child waits until the specified port (pppd passes the path to
11 # the port's device as argument 2) is available and launches pppd (or
12 # whatever is specfied by $PATH_pppd.
14 # This script requires "syslog.pl" (included with perl). Because of
15 # this, it also requires "syslog.ph"; "syslog.ph" can be
16 # manufactured using the h2ph script included with the perl
17 # distribution. Under NeXTSTEP, one can create syslog.ph by:
19 # h2ph < /usr/include/bsd/sys/syslog.h > syslog.ph
21 # 'syslog.ph' should either be copied into your machines perl library
22 # (wherever syslog.pl resides), or you should add wherever syslog.ph
23 # resides to Perl's library search path.
25 # Removing all references to syslog (including openlog() and
26 # closelog()) will also work, but will render this script's execution
29 # By default, this script logs to the default target for ppp's logs --
32 # hacqued by: <bbum@friday.com>, jan 30 1995
34 # Please send any changes/improvements to <bbum@friday.com>. And
35 # please try not to laugh at this code... or, at least, tell me why
36 # you are laughing so I won't make the same mistakes twice.
38 # ABSOLUTE path to PPP daemon (or whatever you want executed after the
39 # port becomes available).
41 $PATH_pppd = "/usr/local/ppp/bin/pppd";
43 # number of seconds to sleep between checking for port availability
50 # this is the parent. It must die so the old pppd can
53 } elsif ($! =~ /No more process/) {
54 # oops! ran out of processes. This is supposed to be a
55 # recoverable error, so sleep and try again.
58 } elsif (!defined($pid)) {
59 # fork error -- log it and die.
60 &openlog("pppd/ip-down", 'cons,pid', LOG_LOCAL2);
64 die "can't fork: $!\n";
68 # everything from here down is the child.
69 &openlog("pppd/ip-down", 'cons,pid', LOG_LOCAL2);
72 # no arguments -- exec specified thing (assume the process
73 # being called has a clue about what port it should use)
75 &syslog('info', "No device specified. Executing '$PATH_pppd'.");
79 ## NOT REACHED: exec never returns
82 # (assume-- it will if pppd starts ip-down)
84 # interface-name tty-device speed local-IP-address
90 $remote_IP_address) = @ARGV;
92 # find the raw device name
93 @path = split ('/', $tty_device);
96 # Generate path to lock file -- assumes NeXT style device locking
97 $lock = "/usr/spool/uucp/LCK/LCK..$device";
101 "Reconnecting '$interface_name' ($local_IP_address:$remote_IP_address) through '$tty_device' at '$speed' baud.");
107 "'$device' locked. Waiting for unlock.");
109 # loop until unlocked
115 #### port available -- log and execute
118 "Port '$device' available. Launching '$PATH_pppd'");