Subject: Re: "smart" ppp scripts?
To: None <port-mac68k@NetBSD.ORG>
From: Brian Andresen <btandresen@ucdavis.edu>
List: port-mac68k
Date: 03/14/1997 18:24:42
On Fri, 14 Mar 1997, synapse wrote:
> i was wondering if the ppp scripts on the macbsd.com server were "smart"
> and redialed when disconnected (by remote connection, or modem shut off,
Somewhat following a suggestion on netbsd-help (or netbsd-users?) and
somewhat hacking on my own, I've pieced together a "pppd daemon". I guess
that would be "pppdd". ;-)
#!/bin/csh
while (1)
set p=`/usr/local/bin/newping -o -c 3 198.93.80.102 |& grep -c route`
if ( $p != 0 ) then
# It's down!
echo "IP link down - restarting PPP" >> /var/log/ppp
set p=`cd /proc; grep -l '^pppd' */status`
if ( $p != "" ) then
kill `cat /var/run/ppp0.pid`
endif
sleep 3
stty -f /dev/tty00 clocal
pppd
endif
sleep 900
end
Now I'll explain the quirks... newping is a slightly modified version of
the regular ping, where the diff output was posted by the guy who
suggested this on the list. I think that in the convoluted way I'm using
it, the regular ping would work just as well. I found that if my ppp
connection was down, each ping attempt would yield "no route to host"...
so use a very ugly kludge and simply check to see if "route" is returned
in the ping output. If so, it restarts the ppp connection, after writing
a very non-informative line to /var/log/ppp (I've meant to have it write
the date & time, too, but I haven't gotten around to it).
This whole thing is completely a result of cut-and-paste work, so I'd
gladly accept suggestions on how to better go about this task. At least
it somehwat works in its current state -- it's better than I expected of
myself!
HTH,
Brian