Weird PPP trouble

Jacob Langseth dragon at cc.gatech.edu
Thu Jan 18 13:22:10 EST 1996


| :Specifically, this means that pppd (or more likely chat)
| :cannot open the serial port again after it dies, which is
| :fantastically aggravating to me, as I have cause to bring
| :the link up and down fairly frequently.
| 
| Actually this sounds like your line is not being hung up properly
| after pppd is killed. Hence chat can't dial becuase it is expecting
| the modem to be in "command" mode. (chat is not smart enough to send
| +++ ATH sequences that will hang up the modem).

I use the following script for making sure the ppp link is down, it should
accomplish what you need.  I've setup a cron job for making sure the PPP
link is really active, and it will bring pppd down and re-establish the
connection if the ping times out.  This is the script that is used to
bring down the link:

<---------------------- ppp-off --------------------->
#!/bin/sh
# ppp-off
# terminates PPP connection and makes sure everything is cleaned up
#
# 09/12/95 jl	updated to use system log facilities
# 07/28/95 jl	changed lock file location for latest pppd (v2.1.2d)
# 04/12/95 jf	Took out extra logging info
# 03/15/95 jf	added code to improve hangup
# 03/01/95 jl	created

PPP_DIR="/usr/lib/ppp"
ACTIVE="no"
DEVICE="cua1"
CONNECTION="ppp0"
LOCK_DIR="/var/lock"
DEV_SPEED="38400"

# crond passes an argument to prevent logging from going
# to STDOUT as well as the log file
if [ $# -gt 0 ]; then
    print () { logger -ip local2.info -t ppp-off $*; }
else
    print () { logger -isp local2.info -t ppp-off $* 2>&1; }
fi

# See if pppd is active
print "checking for pppd"
if [ -f /var/run/$CONNECTION.pid ]; then
   ACTIVE="yes"
   PPP_PID=`cat /var/run/$CONNECTION.pid`
fi

# If the link was determined to be active, stop it.
if [ "$ACTIVE" = "yes" ]; then
    print "Killing $CONNECTION process"
    kill -INT $PPP_PID
    sleep 1

    # Make sure that the pid file is removed.
    if [ -f /var/run/$CONNECTION.pid ]; then
	print "Removing stale /var/run/$CONNECTION.pid"
	/bin/rm -f /var/run/$CONNECTION.pid
    fi

    # Make sure the lock was removed
    if [ -f "$LOCK_DIR/LCK..$DEVICE" ]; then
	print "Removing stale lock file"
	rm -f $LOCK_DIR/LCK..$DEVICE
    fi

    print "$CONNECTION link terminated"

else
    print "$CONNECTION link is not active"

    # check if the lock file still exists
    if [ -f "$LOCK_DIR/LCK..$DEVICE" ]; then
	print "Removing stale lock file"
	/bin/rm -f $LOCK_DIR/LCK..$DEVICE
    fi

# we will try to hang it up anyways
#  exit 1
fi


# Attempt to hangup modem now
print "attempting to hangup modem"
(
    stty $DEV_SPEED -tostop
    if $PPP_DIR/chat -v -t 10 -l LCK..$DEVICE ABORT ERROR '' \
	'+\p+\p+\c' 'OK' ATH 'OK'
    then
	print "got modem's attention"
    else
	print "Failed to get modem's attention"
	if $PPP_DIR/chat -v -t 10 -l LCK..$DEVICE ABORT ERROR '' \
		'AT' OK-'AT&FE1'-OK
	then
		print "modem already onhook"
	else
		print "failed to get modem via break"
	fi
    fi

#    stty $DEV_SPEED -tostop
    if $PPP_DIR/chat -v -t 10 -l LCK..$DEVICE ABORT OK '' \
      AT\&F\&B1\&C2\&D3s14=1\&W 'OK'
    then
	print "Modem reset ok" 1>&2
    else
	print "Modem failed to reset" 1>&2
    fi
) < /dev/$DEVICE >> /dev/$DEVICE
/bin/rm -f $LOCK_DIR/LCK..$DEVICE

#EOF#
<---------------------- ppp-off --------------------->

-- 
 Jacob Langseth  |  Meddle not in the affairs of dragons, for
   (Musashi)     |  thou art crunchy and go well with ketchup _
 =---------------+-----+--------------------------------------+
 dragon at cc.gatech.edu  | Finger for PGP key ..................|






More information about the Ale mailing list