1
0
This repository has been archived on 2025-01-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Anderson Luiz Alves 0464e230c1 stock 103961
2017-07-30 16:48:04 -03:00

59 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# /etc/bewan/scripts/ip-down
# common script for DHCP client et PPP client on the WAN side
# env: $WANID $IFNAME
WANID=${WANID:-0}
base_log "$SCRIPTD/ip-down $WANID started" debug
IFDIR=$WAND/$WANID/ip
[ ! -d "$IFDIR" ] && return
if [ "$IFDIR" != "" ]; then
rm -f $IFDIR/ipaddr
rm -f $IFDIR/ipmask
rm -f $IFDIR/ipremote
rm -f $IFDIR/routers
rm -f $IFDIR/servers
rm -f $IFDIR/dhcpsrv
rm -f $IFDIR/ip-up-env
if [ -f $IFDIR/uptime ]; then
cp -f $IFDIR/uptime $IFDIR/prevuptime
cp -f /proc/uptime $IFDIR/downtime
rm -f $IFDIR/uptime
fi
fi
base_call_scripts 'update-routes update-nat update-dns'
# compute args: $WANID $DEFRTE $INET
# Default route flag
DEFROUTE=`cat $WAND/defroute 2>/dev/null`
DEFRTE=0
if [ "$DEFROUTE" = "$WANID" ] || [ -d "$ROUTED/wan$WANID/default" ]; then
DEFRTE=1
fi
# Internet connection flag
INTERNET=`cat $WAND/internet 2>/dev/null`
INET=0
for ix in `strip $INTERNET`; do
[ "$ix" = "$WANID" ] && INET=1
done
# call scripts found in /etc/bewan/ip-down.d directory
# $1: $WANID, index of WAN interface
# $2: $DEFRTE, true if WAN interface is a default route
# $3: $INET, true if WAN interface is an Internet connection
trap base_reboot_on_exit EXIT
for script in `find /etc/bewan/ip-down.d -follow -type f | sort`; do
base_log "$script $WANID" debug
. $script $WANID $DEFRTE $INET
done
trap '' EXIT
[ ! -f $RCRUNNING ] && base_call_initd 'inittab'
# Exit ip-up-down critical section
base_log "$SCRIPTD/ip-down $WANID exited" debug