#!/usr/bin/ash
#
# This shell script helps to change flags (compress/debug) and stop
# the ppp/slip driver, hanging the modem 
#
# Claudio Tantignone (c_tantignone@hotmail.com)
#
#set -x
if [ -f /etc/modem.line ]
then 
    . /etc/modem.line
else
    echo ERROR: cannot find modem file
    exit 1
fi

a=" "
if [ $# != 1 ]
then
     a='x'
else
     a=$1
fi

if [ $a = 'h' ] 
then
   chat -t 10 -b $SPEED "" "\n" "" "\d+++" "" "\dATH0" OK < /dev/$TTY > /dev/$TTY
   exit 1
fi

if [ -f /tmp/serial.pid ]
then 
   if [ $a = 'c' ] 
   then 
      kill -10 `cat /tmp/serial.pid`
   elif [ $a = 'd' ] 
   then
      kill -12 `cat /tmp/serial.pid`
   elif [ $a = 'k' ] 
   then
      kill -15 `cat /tmp/serial.pid`
      rm -f /tmp/serial.pid 
      chat -t 10 -b $SPEED "" "\n" "" "\d+++" "" "\dATH0" OK < /dev/$TTY > /dev/$TTY
   else
      echo Usage: slcp [c]ompress [d]ebug [k]ill [h]ang
   fi
else
   echo Usage: slcp [c]ompress [d]ebug [k]ill [h]ang
   echo ERROR: pid file not present, ppp/slip is not working
fi

