iopsys-feed/inteno-netmodes/files/etc/hotplug.d/iface/01-netmode-handler

42 lines
922 B
Bash
Executable file

#!/bin/sh
[ "$INTERFACE" != "wan" ] && exit
. /lib/functions.sh
. /lib/functions/network.sh
. /lib/functions/netmode.sh
network_get_ipaddr ipaddr $INTERFACE
[ -z "$ipaddr" ] && exit
repeaterready="$(uci -q get netmode.setup.repeaterready)"
curmode="$(uci -q get netmode.setup.curmode)"
if [ "$(get_ip_type $ipaddr)" == "private" ]; then
# flush the ip on br-lan; br-lan will anyhow be deleted.
# this is needed if the ip received on the wan is also from the same net
ip addr flush dev br-lan
# flush iptables in case the MASTER
# tries to configure us before
# firewall is disabled the proper way
iptables -F
disable_firewall 1
else
disable_firewall 0
fi
case "$curmode" in
repeater*)
;;
*)
[ "$repeaterready" == "1" ] || return
if [ "$(netmode_get_ip_type $ipaddr)" == "private" ]; then
wificontrol_takes_over || switch_netmode repeater
else
switch_netmode router
fi
;;
esac