#!/bin/bash # $Id: fctStopAdsl,v 1.12 2005/03/28 21:41:39 Tux Exp $ # Copyright (C) 2003-2005 Olivier Borowski # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Goal : # stop ADSL connexion (do not display anything) # Params : # h = display help # f = kill pppd even if PPPOX=none # s = simple mode (don't use ifup & ifdown scripts => do not requiere ifcfg-ethX) if [ 0 -eq 1 ] ; then # when called from sources folder (when uninstalling) USE_IFUPDOWN=0 PPPOX="pppoa" DELAY_KILL_PPPD=3 else # when called from /usr/local/sbin . /etc/eagle-usb/setvars fi set -- "${@//#--help/-h}" set -- "${@//#--force/-f}" set -- "${@//#--simple/-s}" evalParams() { while getopts "hfs" opt; do case $opt in h ) doInUtf8 echo -e $FCTSTOP_USAGE_MSG ; exit 0 ;; f ) KILLPPP=1 ;; s ) SIMPLE=1 ;; \? ) doInUtf8 echo -e $FCTSTOP_USAGE_MSG ; exit 1 ;; esac done } if [ "$PPPOX" != "none" ] ; then KILLPPP=1 else KILLPPP=0 fi evalParams "$@" if [ $KILLPPP -eq 1 ] ; then # kill pppd (let Nsec after killall to stop properly) if [ ! -z "`pidof pppd`" ] ; then killall -q pppd sleep $DELAY_KILL_PPPD if [ ! -z "`pidof pppd`" ] ; then logger "fctStopAdsl send -9 signal to kill pppd..." sleep 2 killall -9 -q pppd fi fi fi # if the modem is still plugged, modem interface is putted down # if the modem is unplugged, hotplug should already have done that => do nothing INTERFACE=`eaglectrl -i 2>/dev/null` if [ $? -eq 0 ] ; then if [ $USE_IFUPDOWN -eq 1 ] && [ $SIMPLE -eq 0 ] ; then # redirect errors to /dev/null to hide "RTNETLINK answers: No such device or address" ifdown $INTERFACE 2>/dev/null else ifconfig $INTERFACE down fi fi #*************************************************************************** # $Log: fctStopAdsl,v $ # Revision 1.12 2005/03/28 21:41:39 Tux # - translate remaining french sentence to english # # Revision 1.11 2005/01/16 22:04:34 Tux # - add license header # # Revision 1.10 2005/01/04 21:14:05 Tux # - switch strings to utf-8 # # Revision 1.9 2004/11/21 15:29:41 Tux # - replaced == with -eq # # Revision 1.8 2004/09/28 10:11:35 mcoolive # - (POSIX) commands are typed "int main..." => replace "$? ==" by "$? -eq" # # Revision 1.7 2004/09/14 20:44:07 Tux # - hide ifdown errors (prevent messages such as "RTNETLINK answers...") # # Revision 1.6 2004/08/14 18:00:53 mcoolive # - mend the parameters processing # # Revision 1.5 2004/07/16 21:09:19 Tux # - simplify parameters processing # # Revision 1.4 2004/04/21 20:02:27 Tux # *** empty log message *** # #***************************************************************************/