|
|
@ -3,9 +3,12 @@ |
|
|
|
. /lib/functions.sh |
|
|
|
. /lib/functions/network.sh |
|
|
|
. /lib/mwan3/mwan3.sh |
|
|
|
. /usr/share/libubox/jshn.sh |
|
|
|
. /lib/mwan3/common.sh |
|
|
|
|
|
|
|
initscript=/etc/init.d/mwan3 |
|
|
|
. /lib/functions/procd.sh |
|
|
|
|
|
|
|
|
|
|
|
SCRIPTNAME="mwan3-hotplug" |
|
|
|
[ "$ACTION" = "ifup" ] || [ "$ACTION" = "ifdown" ] || [ "$ACTION" = "connected" ] || [ "$ACTION" = "disconnected" ] || exit 1 |
|
|
|
[ -n "$INTERFACE" ] || exit 2 |
|
|
@ -16,18 +19,17 @@ if { [ "$ACTION" = "ifup" ] || [ "$ACTION" = "connected" ] ; } && [ -z "$DEVICE" |
|
|
|
exit 3 |
|
|
|
fi |
|
|
|
|
|
|
|
[ "$MWAN3_STARTUP" = 1 ] || mwan3_lock "$ACTION" "$INTERFACE" |
|
|
|
[ "$MWAN3_STARTUP" = 1 ] || procd_lock |
|
|
|
|
|
|
|
config_load mwan3 |
|
|
|
/etc/init.d/mwan3 running || { |
|
|
|
[ "$MWAN3_STARTUP" = 1 ] || mwan3_unlock "$ACTION" "$INTERFACE" |
|
|
|
[ "$MWAN3_STARTUP" = "init" ] || procd_lock |
|
|
|
LOG notice "mwan3 hotplug $ACTION on $INTERFACE not called because globally disabled" |
|
|
|
mwan3_flush_conntrack "$INTERFACE" "$ACTION" |
|
|
|
exit 0 |
|
|
|
} |
|
|
|
|
|
|
|
$IPT4 -S mwan3_hook &>/dev/null || { |
|
|
|
mwan3_unlock "$ACTION" "$INTERFACE" |
|
|
|
LOG warn "hotplug called on $INTERFACE before mwan3 has been set up" |
|
|
|
exit 0 |
|
|
|
} |
|
|
@ -44,7 +46,6 @@ fi |
|
|
|
|
|
|
|
config_get_bool enabled $INTERFACE 'enabled' '0' |
|
|
|
[ "${enabled}" -eq 1 ] || { |
|
|
|
[ "$MWAN3_STARTUP" = 1 ] || mwan3_unlock "$ACTION" "$INTERFACE" |
|
|
|
LOG notice "mwan3 hotplug on $INTERFACE not called because interface disabled" |
|
|
|
exit 0 |
|
|
|
} |
|
|
@ -57,11 +58,6 @@ else |
|
|
|
status=online |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$ACTION" = ifup ] || [ "$ACTION" = ifdown ]; then |
|
|
|
initscript=/etc/init.d/mwan3 |
|
|
|
. /lib/functions/procd.sh |
|
|
|
fi |
|
|
|
|
|
|
|
LOG notice "Execute $ACTION event on interface $INTERFACE (${DEVICE:-unknown})" |
|
|
|
|
|
|
|
case "$ACTION" in |
|
|
@ -73,8 +69,9 @@ case "$ACTION" in |
|
|
|
mwan3_create_iface_iptables $INTERFACE $DEVICE |
|
|
|
mwan3_create_iface_rules $INTERFACE $DEVICE |
|
|
|
mwan3_set_iface_hotplug_state $INTERFACE "$status" |
|
|
|
if [ "$MWAN3_STARTUP" != 1 ]; then |
|
|
|
if [ "$MWAN3_STARTUP" = "cmd" ]; then |
|
|
|
mwan3_create_iface_route $INTERFACE $DEVICE |
|
|
|
mwan3_set_general_rules |
|
|
|
[ "$status" = "online" ] && mwan3_set_policies_iptables |
|
|
|
fi |
|
|
|
[ "$ACTION" = ifup ] && procd_running mwan3 "track_$INTERFACE" && procd_send_signal mwan3 "track_$INTERFACE" USR2 |
|
|
@ -93,5 +90,4 @@ case "$ACTION" in |
|
|
|
mwan3_set_policies_iptables |
|
|
|
;; |
|
|
|
esac |
|
|
|
[ "$MWAN3_STARTUP" = 1 ] || mwan3_unlock "$ACTION" "$INTERFACE" |
|
|
|
exit 0 |