Browse Source

net/mwan3: fix start/stop/restart execution

Move setting global enabled flag from /etc/init.d/mwan3 to mwan3
command. So we could start mwan3 from the cmd mwan3 as well.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
lilik-openwrt-22.03
Florian Eckert 6 years ago
parent
commit
2cd5442a11
2 changed files with 12 additions and 21 deletions
  1. +3
    -15
      net/mwan3/files/etc/init.d/mwan3
  2. +9
    -6
      net/mwan3/files/usr/sbin/mwan3

+ 3
- 15
net/mwan3/files/etc/init.d/mwan3 View File

@ -3,15 +3,7 @@
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
/usr/sbin/mwan3 restart
}
boot() {
@ -20,13 +12,9 @@ boot() {
}
start() {
. /lib/config/uci.sh
uci_toggle_state mwan3 globals enabled "1"
mwan3 start
/usr/sbin/mwan3 start
}
stop() {
. /lib/config/uci.sh
uci_toggle_state mwan3 globals enabled "0"
mwan3 stop
/usr/sbin/mwan3 stop
}

+ 9
- 6
net/mwan3/files/usr/sbin/mwan3 View File

@ -46,6 +46,12 @@ ifup()
local device enabled up l3_device
config_load mwan3
config_get_bool enabled globals 'enabled' 0
[ ${enabled} -gt 0 ] || {
echo "The service mwan3 is global disabled."
echo "Please execute \"/etc/init.d/mwan3 start\" first."
exit 1
}
if [ -z "$1" ]; then
echo "Expecting interface. Usage: mwan3 ifup <interface>" && exit 0
@ -123,12 +129,7 @@ start()
{
local enabled src_ip local_source
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
}
uci_toggle_state mwan3 globals enabled "1"
config_get local_source globals local_source 'none'
[ "${local_source}" = "none" ] || {
@ -211,6 +212,8 @@ stop()
ip route del default via "${src_ip}" dev lo 1>/dev/null 2>&1
ip addr del "${src_ip}/32" dev lo 1>/dev/null 2>&1
}
uci_toggle_state mwan3 globals enabled "0"
}
restart() {


Loading…
Cancel
Save