#!/bin/sh # ../scripts/pppoe-stop. Generated from pppoe-stop.in by configure. #*********************************************************************** # # pppoe-stop # # Shell script to bring down a PPPoE connection # # Copyright (C) 2000 Roaring Penguin Software Inc. # # $Id: pppoe-stop.in,v 1.2 2005/08/10 00:25:19 dfs Exp $ # # This file may be distributed under the terms of the GNU General # Public License. # # LIC: GPL # # Usage: pppoe-stop [config_file] [numerodeppp modif IMCP] # modif IMCP pour pressiser le numero de ppp a tuer # If config_file is omitted, defaults to /etc/ppp/pppoe.conf # #*********************************************************************** # Set to "C" locale so we can parse messages from commands LANG=C export LANG ME="`basename $0`" LOGGER="/usr/bin/logger -t $ME" # Must be root #modif ICMP ajout if test "`/usr/bin/id -u`" != 0 ; then echo "$0: You must be root to run this script" >& 2 exit 1 fi #modif ICMP ajout extra argument tu stop dedicated CONFIG pppx numppp=''; CONFIG=''; #default config not sytematicly $1 # CONFIG="$1" case "$#" in 0) ;; 1) CONFIG="$1"; numppp="$1"; numppp="$[0 + $numppp]"; if test "$?" == '0'; then #numerique CONFIG=''; #default config else numppp=''; fi; ;; *) CONFIG="$1"; numppp="$2"; ;; esac; if [ "$CONFIG" = "" ] ; then CONFIG=/etc/ppp/pppoe.conf fi if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then echo "$ME: Cannot read configuration file '$CONFIG'" >& 2 exit 1 fi export CONFIG . $CONFIG PPPOE_PIDFILE="$PIDFILE.pppoe" PPPD_PIDFILE="$PIDFILE.pppd" STARTPID="$PIDFILE.start" # Backward config file compatibility if test "$DEMAND" = "" ; then DEMAND=no fi # Ignore SIGTERM trap "" 15 #modif IMCP pour selecterr un pppoe donne passe en parametre ---------------- if test "$numppp" != ''; then numppp="$[0 + $numppp]"; if test "$?" == '0'; then #si parametre numerique FPID=''; ifchange=''; echo " ---------------- ppp${numppp} ?"; #kokkkkk IMCP for fpi in /etc/ppp/ppp${numppp}.pid /var/run/ppp${numppp}.pid ; do #find pppd if [ -r $fpi ] ; then #find FPID=`cat $fpi`; kill -0 $FPID > /dev/null 2>&1; if test "$?" == '0'; then # echo "$FPID" >$PIDFILE; #force update the file b((mais c'est pas la bonne : pppd au lieu deconnect) echo -e "IMCP : to kill ($FPID ppp${numppp})\a\a\a\a"; ifchange='ok'; fi; break; #on first file fi; done if test "$ifchange" == ''; then echo "$ME: No PPPd $numppp appears ..." >&2 exit 1; fi; PPPDCONT=''; #controler avec courant IMCP i="$PPPD_PIDFILE"; if [ -r $i ] ; then #find PPPDCONT=`cat $i`; fi; if test "$PPPDCONT" != "$FPID"; then # c'est pas le meme pppd IMCP #il fo auusi perventivement tuer ancetre connect PPPDPARENT="`ps -l $FPID | grep $FPID | (read a b c d e f; echo $e)`"; if test "$PPPDPARENT" != '1'; then #not reparented kill $PPPDPARENT > /dev/null 2>&1 || ( echo "Cannot Kill pppoe-connect ($PPPDPARENT) !!!! ">& 2 exit 1 ; #exit if not kill ) echo "pppoe-connect ($PPPDPARENT) Killed ... ">& 2 fi; #tuer pppd kill $FPID > /dev/null 2>&1 || exit 1 ; #exit if not kill rm -r $fpi; #delet file exit 0; fi; fi; fi; # IMCP # retour dans la procedure normale IMCP ------------------------------------------ # Check for pidfile if [ -r "$PIDFILE" ] ; then # of connect PID=`cat $PIDFILE`; echo "$ME: The connect (PID $PID) !" >& 2 #KOKKKKKKKKKKKKKKKKKKKKKKKk # Check if still running kill -0 $PID > /dev/null 2>&1 if [ $? != 0 ] ; then echo "$ME: The pppoe-connect script (PID $PID) appears to have died" >& 2 fi # Kill pppd, which should in turn kill pppoe if [ -r "$PPPD_PIDFILE" ] ; then PPPD_PID=`cat "$PPPD_PIDFILE"` $LOGGER -p daemon.notice "Killing pppd" echo "Killing pppd ($PPPD_PID)" >& 2 #KOKKKKKKKKKKKKKKKKKKKKKKKk kill $PPPD_PID > /dev/null 2>&1 || exit 1 ; #exit if not kill fi # Kill pppoe-start PIDS=`cat $STARTPID` kill -0 $PIDS > /dev/null 2>&1 if [ $? = 0 ] ; then $LOGGER -p daemon.notice "Killing pppoe-start" kill $PIDS > /dev/null 2>&1 fi # Kill pppoe-connect $LOGGER -p daemon.notice "Killing pppoe-connect" echo "Killing pppoe-connect ($PID)" kill -9 $PID > /dev/null 2>&1 # Kill pppd again, in case it's still hanging around if [ -r "$PPPD_PIDFILE" ] ; then PPPD_PID=`cat "$PPPD_PIDFILE"` kill -9 $PPPD_PID > /dev/null 2>&1 || exit 1 fi rm -f "$PIDFILE" "$PPPD_PIDFILE" "$PPPOE_PIDFILE" "$STARTPID" else echo "$ME: No PPPoE connection appears to be running" >&2 fi exit 0 #Retour a la page d'appel du web source # |