#!/bin/sh

# PPP-Script 1.0.0
# Written by (Karsten Johansson) ksaj@ims.pcscav.com
# Sat Dec 2, 1995

# Edit 'if /etc/ppp/chat' line accordingly, then run
# 'uptest' regularly in cron.  Will keep pppd running
# in the background without a connected shell, and
# fixes periodic line hangups.


MODEM=cua2
DEVICE=ppp0

cd /etc/ppp

ppp-down		# Quick way to make sure of no PID files, etc...
rm -f /var/lock/LCK..$MODEM
rm -f /var/run/$DEVICE.pid
rm -f /etc/ppp-down
/usr/bin/chown root /dev/$MODEM
/usr/bin/chmod 666 /dev/$MODEM

(
  stty 38400 echo
  if /etc/ppp/chat -v -l LCK..$MODEM ABORT "NO CARRIER" ABORT BUSY "" "ATZ"
  then
    /usr/bin/doshell /dev/$MODEM /etc/ppp/pppd
  else
    echo There was an error.  Try again later...
  fi
) < /dev/$MODEM > /dev/$MODEM
