1#!/bin/sh 2# @configure_input@ 3#*********************************************************************** 4# 5# adsl-stop 6# 7# Shell script to bring down an ADSL connection 8# 9# Copyright (C) 2000 Roaring Penguin Software Inc. 10# 11# $Id: adsl-stop.in,v 1.1.1.1 2008/10/15 03:31:00 james26_jang Exp $ 12# 13# This file may be distributed under the terms of the GNU General 14# Public License. 15# 16# Usage: adsl-stop [config_file] 17# If config_file is omitted, defaults to /etc/ppp/pppoe.conf 18# 19#*********************************************************************** 20 21ME="`basename $0`" 22LOGGER="/usr/bin/logger -t $ME" 23CONFIG="$1" 24if [ "$CONFIG" = "" ] ; then 25 CONFIG=/etc/ppp/pppoe.conf 26fi 27 28if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then 29 echo "$ME: Cannot read configuration file '$CONFIG'" >& 2 30 exit 1 31fi 32 33. $CONFIG 34 35PPPOE_PIDFILE="$PIDFILE.pppoe" 36PPPD_PIDFILE="$PIDFILE.pppd" 37 38# Backward config file compatibility 39if test "$DEMAND" = "" ; then 40 DEMAND=no 41fi 42 43# Ignore SIGTERM 44trap "" 15 45 46# Check for pidfile 47if [ -r "$PIDFILE" ] ; then 48 PID=`cat $PIDFILE` 49 50 # Check if still running 51 kill -0 $PID > /dev/null 2>&1 52 if [ $? != 0 ] ; then 53 echo "$ME: The adsl-connect script (PID $PID) appears to have died" >& 2 54 exit 1 55 fi 56 57 # Kill adsl-connect 58 $LOGGER -p daemon.notice "Killing adsl-connect" 59 echo "Killing adsl-connect ($PID)" 60 kill $PID > /dev/null 2>&1 61 62 # Kill pppd, which should in turn kill pppoe 63 if [ -r "$PPPD_PIDFILE" ] ; then 64 PID=`cat "$PPPD_PIDFILE"` 65 $LOGGER -p daemon.notice "Killing pppd" 66 echo "Killing pppd ($PID)" 67 kill $PID > /dev/null 2>&1 68 fi 69 70 rm -f "$PIDFILE" "$PPPD_PIDFILE" "$PPPOE_PIDFILE" 71else 72 echo "$ME: No ADSL connection appears to be running" >&2 73 exit 1 74fi 75 76exit 0 77