summaryrefslogtreecommitdiff
path: root/templates/disconnect/interface/node.tag/node.def
blob: 4a937b9f44754cc7df057f6e2f0fa33e2848c851 (plain)
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
help: Bring connection-oriented interface down

allowed: local -a array ;
         array=( /etc/ppp/peers/pppoe* /etc/ppp/peers/pppoa* /etc/ppp/peers/wan* /etc/ppp/peers/wlm* ) ;
         echo  -n ${array[@]##*/}

run:
	IFNAME=${3}
	LOGFILE=/var/log/vyatta/ppp_${IFNAME}.log
        if [ ! -e /etc/ppp/peers/${IFNAME} ]; then
                echo "Invalid interface: $IFNAME"
        elif [  -z "`ps -C pppd -f | grep $IFNAME`" ]; then
                echo "Interface $IFNAME: Connection is already down"
	else 
		# Serial PPP interfaces are started with "pon", which
	        # lingers around as a watchdog process.  Sometimes
	        # multiple "pon" scripts are running.  So we need to kill
	        # all pon scripts relating to this interface before
	        # before killing the pppd process
		if [ "${IFNAME::3}" = "wan" ]; then
		    PON_PIDS=` ps -C pon -f | grep $IFNAME | awk '{print $2}'`
		    if [ -n "$PON_PIDS" ]; then
			echo "killing pon pids: $PON_PIDS"
			for PID in $PON_PIDS ; do
			    sudo kill -HUP $PID
			done
		    fi
		fi

                echo "Bringing interface $IFNAME down..."
		echo "`date`: User $USER stopping PPP daemon for $IFNAME by disconnect command" >> $LOGFILE
                sudo /usr/bin/poff $IFNAME
	fi