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

56 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# /etc/bewan/scripts/waneth-up
# called when cable is plugged in WAN Ethernet port
# $1 : WANETHID
WANETHID=${WANETHID:-}
if [ "$WANETHID" = '' ]; then
WANETHID=${1:-}
fi
. /etc/bewan/scripts/globals
. /etc/bewan/lib/base
. /etc/bewan/lib/phy
main_waneth_up() {
base_log "$SCRIPTD/waneth-up" debug
# Take onchange mutex
base_enter_critical 'onchange'
# Get config parameters after taking lock, else parameters could be outdated
base_call_initd 'setparam'
# Check the associated phy state
local phy_state=''
retrieve_phy_state WANEthernetInterface ${WANETHID}
if [ "$phy_state" -eq "1" ] && [ ! -f $WANETHD/wanethup_${WANETHID} ]; then
base_log "$SCRIPTD/waneth-up entered" debug
# Create flag file
touch $WANETHD/wanethup_${WANETHID}
NOIPT=1
for script in `find /etc/bewan/waneth-up.d -follow -type f 2>/dev/null | sort`; do
base_log "$script up $WANETHID" debug
. $script up $WANETHID
done
# Restart netfilter
IPPROTO=
ARG=restart
base_call_initd 'fwrules iptables ip6tables'
base_call_initd 'inittab'
# Exit waneth-up-down critical section
base_log "$SCRIPTD/waneth-up exited" debug
fi
# Release onchange mutex
base_exit_critical 'onchange'
}
main_waneth_up