54 lines
1.2 KiB
Bash
Executable File
54 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# Network interface is down (from PPP client)
|
|
# Environnement variables:
|
|
|
|
# IFNAME: $1, interface name (pppi)
|
|
|
|
IFNAME=${1:-}
|
|
|
|
. /etc/bewan/scripts/globals
|
|
. /etc/bewan/lib/base
|
|
|
|
base_log "$SCRIPTD/ip-down-ppp $IFNAME" debug
|
|
|
|
# PPP down on WAN interface
|
|
[ -f "$INTFD/$IFNAME/wanid" ] || exit 0
|
|
WANID=`cat $INTFD/$IFNAME/wanid`
|
|
|
|
# Take wan-up-down mutex
|
|
base_enter_critical 'wan-up-down'
|
|
|
|
# Get config parameters after taking lock
|
|
base_call_initd 'setparam'
|
|
|
|
# PPP on demand
|
|
# Triggers a down / up on the interface
|
|
# The SNAT module is listening to this kind of event
|
|
# and will flush the conntrack table
|
|
if [ -f "$WAND/$WANID/ip/fakeip" ]; then
|
|
ifconfig $IFNAME down up
|
|
fi
|
|
# Continues with main ip-down script
|
|
base_call_scripts 'ip-down'
|
|
|
|
# Release wan-up-down mutex
|
|
base_exit_critical 'wan-up-down'
|
|
|
|
|
|
|
|
# Alacn, 2017-01-26
|
|
# pppd doesn't call ppp-down6 on reconnect
|
|
if [ -f /var/run/ppp-$IFNAME.pid ] &&
|
|
[ -f $WAND/$WANID/ppp6.pid ]
|
|
then
|
|
local pid=`cat /var/run/ppp-$IFNAME.pid`
|
|
local pid6=`cat $WAND/$WANID/ppp6.pid`
|
|
|
|
if [ ! -z "$pid" ] && [ "$pid" = "$pid6" ]
|
|
then
|
|
base_log "$SCRIPTD/ip-down-ppp alacn fix: calling ppp-down6" debug
|
|
. $SCRIPTD/ppp-down6
|
|
fi
|
|
fi
|
|
|