Browse Source

net/mwan3: add init script to enable/disable mwan3 globally

Adding a init script to "/etc/init.d/" introduce the possibility to
enable/disable mwan3 globally.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
lilik-openwrt-22.03
Florian Eckert 7 years ago
parent
commit
f9a787e8df
5 changed files with 59 additions and 4 deletions
  1. +3
    -0
      net/mwan3/files/etc/hotplug.d/iface/14-mwan3
  2. +7
    -4
      net/mwan3/files/etc/hotplug.d/iface/15-mwan3
  3. +3
    -0
      net/mwan3/files/etc/hotplug.d/iface/16-mwan3-user
  4. +32
    -0
      net/mwan3/files/etc/init.d/mwan3
  5. +14
    -0
      net/mwan3/files/usr/sbin/mwan3

+ 3
- 0
net/mwan3/files/etc/hotplug.d/iface/14-mwan3 View File

@ -12,6 +12,9 @@ if [ "$ACTION" = "ifup" ]; then
fi
config_load mwan3
config_get_bool enabled globals 'enabled' '0'
[ ${enabled} -gt 0 ] || exit 0
config_get local_source globals local_source 'none'
[ "${local_source}" = "none" ] && {
exit 0


+ 7
- 4
net/mwan3/files/etc/hotplug.d/iface/15-mwan3 View File

@ -12,15 +12,18 @@ if [ "$ACTION" == "ifup" ]; then
[ -n "$DEVICE" ] || exit 3
fi
mwan3_lock
mwan3_set_connected_iptables
mwan3_unlock
config_load mwan3
config_get_bool enabled globals 'enabled' '0'
[ ${enabled} -gt 0 ] || exit 0
config_get enabled $INTERFACE enabled 0
config_get initial_state $INTERFACE initial_state "online"
[ "$enabled" == "1" ] || exit 0
mwan3_lock
mwan3_set_connected_iptables
mwan3_unlock
if [ "$ACTION" == "ifup" ]; then
config_get family $INTERFACE family ipv4
if [ "$family" = "ipv4" ]; then


+ 3
- 0
net/mwan3/files/etc/hotplug.d/iface/16-mwan3-user View File

@ -4,6 +4,9 @@
. /lib/functions.sh
config_load mwan3
config_get_bool enabled globals 'enabled' '0'
[ ${enabled} -gt 0 ] || exit 0
config_get enabled "$INTERFACE" enabled 0
[ "${enabled}" = "1" ] || exit 0
env -i ACTION="$ACTION" INTERFACE="$INTERFACE" DEVICE="$DEVICE" \


+ 32
- 0
net/mwan3/files/etc/init.d/mwan3 View File

@ -0,0 +1,32 @@
#!/bin/sh /etc/rc.common
START=19
reload() {
local enabled
config_load mwan3
config_get_bool enabled globals 'enabled' 0
[ ${enabled} -gt 0 ] || {
echo "Warning: mwan3 is global disabled. Usage: /etc/init.d/mwan3 start"
exit 0
}
mwan3 restart
}
boot() {
. /lib/config/uci.sh
uci_toggle_state mwan3 globals enabled "1"
}
start() {
. /lib/config/uci.sh
uci_toggle_state mwan3 globals enabled "1"
mwan3 start
}
stop() {
. /lib/config/uci.sh
uci_toggle_state mwan3 globals enabled "0"
mwan3 stop
}

+ 14
- 0
net/mwan3/files/usr/sbin/mwan3 View File

@ -54,6 +54,12 @@ ifup()
echo "Too many arguments. Usage: mwan3 ifup <interface>" && exit 0
fi
config_get_bool enabled globals 'enabled' 0
[ ${enabled} -gt 0 ] || {
echo "Warning: mwan3 is global disabled. Usage: /etc/init.d/mwan3 start"
exit 0
}
config_get enabled "$1" enabled 0
device=$(uci -p /var/state get network.$1.ifname) &> /dev/null
@ -112,7 +118,15 @@ status()
start()
{
local enabled
config_load mwan3
config_get_bool enabled globals 'enabled' 0
[ ${enabled} -gt 0 ] || {
echo "Warning: mwan3 is global disabled. Usage: /etc/init.d/mwan3 start"
exit 0
}
config_foreach ifup interface
}


Loading…
Cancel
Save