icwmp: do not use local out of function

This commit is contained in:
Sukru Senli 2018-01-02 16:46:15 +01:00
parent cf5327b44c
commit 019d6c3a00

View file

@ -4,39 +4,45 @@
[ "$ACTION" == "ifup" ] || exit 0 [ "$ACTION" == "ifup" ] || exit 0
local islan="$(uci -q get network.$INTERFACE.is_lan)" [ -f /etc/config/cwmp ] || exit 0
[ "$islan" == "1" ] && exit 0
local proto="$(uci -q get network.$INTERFACE.proto)" handle_icwmp_reload() {
[ "$proto" == "none" ] && exit 0 local islan="$(uci -q get network.$INTERFACE.is_lan)"
[ "$islan" == "1" ] && exit 0
local ifname="$(uci -q get network.$INTERFACE.ifname)" local proto="$(uci -q get network.$INTERFACE.proto)"
[ "${ifname:0:1}" == "@" ] && exit 0 [ "$proto" == "none" ] && exit 0
mkdir -p /tmp/ipv4 local ifname="$(uci -q get network.$INTERFACE.ifname)"
[ "${ifname:0:1}" == "@" ] && exit 0
local previpaddr="" mkdir -p /tmp/ipv4
local curipaddr=""
local ipaddrfile=/tmp/ipv4/$INTERFACE-ipaddr
previpaddr=$(cat $ipaddrfile 2>/dev/null)
network_get_ipaddr curipaddr $INTERFACE
[ -n "$curipaddr" ] && echo $curipaddr > $ipaddrfile || rm -f $ipaddrfile
local prevgateway="" local previpaddr=""
local curgateway="" local curipaddr=""
local gatewayfile=/tmp/ipv4/$INTERFACE-gateway local ipaddrfile=/tmp/ipv4/$INTERFACE-ipaddr
prevgateway=$(cat $gatewayfile 2>/dev/null) previpaddr=$(cat $ipaddrfile 2>/dev/null)
network_get_gateway curgateway $INTERFACE network_get_ipaddr curipaddr $INTERFACE
[ -n "$curgateway" ] && echo $curgateway > $gatewayfile || rm -f $gatewayfile [ -n "$curipaddr" ] && echo $curipaddr > $ipaddrfile || rm -f $ipaddrfile
local prevsubnets="" local prevgateway=""
local cursubnets="" local curgateway=""
local subnetsfile=/tmp/ipv4/$INTERFACE-subnets local gatewayfile=/tmp/ipv4/$INTERFACE-gateway
prevsubnets=$(cat $subnetsfile 2>/dev/null) prevgateway=$(cat $gatewayfile 2>/dev/null)
network_get_subnets cursubnets $INTERFACE network_get_gateway curgateway $INTERFACE
[ -n "$cursubnets" ] && echo $cursubnets > $subnetsfile || rm -f $subnetsfile [ -n "$curgateway" ] && echo $curgateway > $gatewayfile || rm -f $gatewayfile
[ "$previpaddr" = "$curipaddr" -a "$prevgateway" = "$curgateway" -a "$prevsubnets" = "$cursubnets" ] && exit 0 local prevsubnets=""
local cursubnets=""
local subnetsfile=/tmp/ipv4/$INTERFACE-subnets
prevsubnets=$(cat $subnetsfile 2>/dev/null)
network_get_subnets cursubnets $INTERFACE
[ -n "$cursubnets" ] && echo $cursubnets > $subnetsfile || rm -f $subnetsfile
[ -f /etc/config/cwmp ] && /etc/init.d/icwmpd reload & [ "$previpaddr" = "$curipaddr" -a "$prevgateway" = "$curgateway" -a "$prevsubnets" = "$cursubnets" ] && exit 0
/etc/init.d/icwmpd reload &
}
handle_icwmp_reload