Next Previous Contents

9. le fichier /usr/sbin/ppp-go

Voici le fichier /usr/sbin/ppp-go fabriqu? par la distribution Slackware 3.4.0 . Il en vaut bien un autre. ppp-go est le nom de la commande pour lancer pppd, et initier la communication t?l?phonique.


#!/bin/bash

if [ "$1" = "-h" ]; then
echo "USAGE: ppp-go     <Connect print messages to screen.>"
echo "USAGE: ppp-go -c  <Remove contents of /var/log/pppd files.>"
echo "USAGE: ppp-go -cc <Remove contents of /var/log/messages & debug files.>"
echo "USAGE: ppp-go -d  <Put pppd in demand dialing mode.>"
echo "USAGE: ppp-go -h  <help>"
echo "USAGE: ppp-go -s Nseconds <Connect do not print messages to screen.>"
echo "USAGE: ppp-go -s 50       <Put any Number of seconds to connect.>"
exit
fi

if [ "$1" = "-c" ]; then
cat /dev/null >/var/log/pppd.chat.log >/var/log/pppd.debug.log
echo "Contents of /var/log/pppd files removed."
exit
fi

if [ "$1" = "-cc" ]; then
cat /dev/null >/var/log/messages >/var/log/debug
echo "Contents of /var/log/messages & debug files removed."
exit
fi

if [ "$1" = "-d" ]; then
kill -9 2>/dev/null `cat /var/run/ppp*.pid 2>/dev/null`
rm -f /var/spool/uucp/LCK* /var/lock/LCK* /var/run/ppp*.pid
/usr/sbin/pppd file "/etc/ppp/options.demand" || exit 1
echo "Demand Dialing Started..."
exit
fi

if [ "$1" = "" ]; then
kill -9 2>/dev/null `cat /var/run/ppp*.pid 2>/dev/null`
rm -f /var/spool/uucp/LCK* /var/lock/LCK* /var/run/ppp*.pid
/usr/sbin/pppd connect "/usr/sbin/chat -v -f /etc/ppp/pppscript"

if [ -f /var/log/pppd.chat.log ]; then
tail -c 0 -f /var/log/pppd.chat.log &
read
trap "" 9
killall -9 tail 2>/dev/null
fi

if /sbin/ifconfig | grep P-t-P >/dev/null ; then
echo
echo "* YES! connected... *"
echo
exit
else
echo
echo "* NO! not connected... *"
echo
exit
fi
fi

if [ "$1" = "-s" ]; then
if [ ! "$2" = "" ]; then
kill -9 2>/dev/null `cat /var/run/ppp*.pid 2>/dev/null`
rm -f /var/spool/uucp/LCK* /var/lock/LCK* /var/run/ppp*.pid
/usr/sbin/pppd connect "/usr/sbin/chat -v -f /etc/ppp/pppscript"
echo "Waiting "$2" seconds to connect..."
sleep "$2" || kill -9 2>/dev/null `cat /var/run/ppp*.pid 2>/dev/null`
else
echo "USAGE: ppp-go -s Nseconds"
exit 1
fi
fi

if [ "$?" = "0" ]; then
if /sbin/ifconfig | grep P-t-P >/dev/null &&
[ -s /etc/ppp/connect-errors ]; then
echo
echo "* YES! connected... *"
if ! grep "connect-errors" /etc/ppp/connect-errors >/dev/null
then
tail -n 1 /etc/ppp/connect-errors
echo
exit
else
tail -n 2 /etc/ppp/connect-errors
echo
exit
fi
fi

if /sbin/ifconfig | grep P-t-P >/dev/null ; then
echo
echo "* YES! connected... *"
echo
exit
else
echo
echo "* NO! not connected... *"
echo
tail -n 4 /var/log/pppd.chat.log 2>/dev/null
echo
exit
fi
fi


Next Previous Contents