1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#!/bin/bash
# $Id: fctStopAdsl,v 1.11 2005/01/16 22:04:34 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 [ 1 -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
exit 123
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 "2e tape stopadsl"
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.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 ***
#
#***************************************************************************/
|