sliphangup  -  Version 1.4
--------------------------

Copyright (C) Karl Keyte, 1994-1996              kkeyte@koft.rhein-main.de
-----------------------------------              -------------------------

sliphangup is a program designed to kill a 'dip' SLIP connection after
a time of inactivity.  Normally it would be included in a script used
to make a 'dip' connection.  When the line is detected to be inactive
for a specified (or defaulted) amount of time, it is dropped CLEANLY
by requesting 'dip' to shut-down the line.  This is important because
the line should be reset to a known state.

As an example, I connect to the internet using a crontab entry to
make the connection and another to close the connection.  Here are
my entries:

0 18 * * * /usr/local/scripts/slip-connect
5 18 * * * /usr/local/scripts/slip-disconnect

This allows a 5 minute connection time, regardless of what is being
done.  What I want is for the line to stay open as long as necessary,
subject to a sensible maximum for safety.  Using 'sliphangup' I can
safely change the second line to:

0 19 * * * /usr/local/scripts/slip-disconnect

Which will close the line after one hour - if it hasn't already been
closed by 'sliphangup'.  Here is my slip-connect script.  You may
have different requirements:

#!/bin/sh
PATH=/sbin:/usr/sbin:/usr/bin:/usr/lib
dip /usr/local/etc/slip.dip >& /dev/null
sleep 2
grep "^sl0" /proc/net/route >& /dev/null
if [ $? != 0 ]; then
   exit
fi
netdate odb.rhein-main.de >& /dev/null
clock -u -w
sendmail -q
sliphangup 60
exit

This makes the connection using the slip.dip script.  If the connection
fails, the script drops out.  If it succeeds, it sets the date from the
network, transfers mail and waits until 60 seconds of continuous activity
are detected.  At this point the line will drop.

My slip-disconnect script is even simpler:

#!/bin/sh
/sbin/dip -k >& /dev/null
exit

Which just performs a forced kill - to be safe!

Try it and let me know if you have problems.  I don't!


NOTICE
======
I take NO responsibility for any phone bills!  If the line doesn't
hang-up and you have no guard to forcibly hang-up - your problem -
try it out whilst watching the modem first!  From version 1.4 there
is a lot more checking to ensure that the line doesn't just stay
open - should be a lot safer.

Have fun!

Karl
