1
0
mirror of https://git.openwrt.org/feed/routing.git synced 2024-06-17 20:54:02 +02:00
openwrt-routing/vis/files/etc/init.d/vis
Sven Eckelmann aa050789fe vis: Convert to procd based init script
The legacy init script had various problems in comparison with procd based
init scripts. It wasn't able to correctly track the running process
instance and thus could:

* accidentally kill another (non init controlled) daemon instance when stop
  is used
* not restart the daemon depending on config changes when reload is used
* not automatically start/restart daemon when the used netdev was
  created/recreated

The information about a running instance and its parameters can now be
handled by a global controller (procd). The process must not fork anymore
and leave the control to procd. The process with its parameters can then be
used by procd to trigger the stop/start of the process at the right time.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-07-28 00:17:42 +02:00

37 lines
727 B
Bash

#!/bin/sh /etc/rc.common
START=90
USE_PROCD=1
vis_start() {
local config="$1"
local interface
[ "$config" = "general" ] || return 1
config_get interface "$config" interface
if [ "$interface" = "" ]; then
echo $1 Error, you must specify at least a network interface
return 1
fi
procd_open_instance "${config}"
procd_set_param command /usr/sbin/vis
procd_append_param command -D
procd_append_param command ${interface}
procd_set_param netdev $interface
procd_close_instance
}
start_service() {
config_load "vis"
config_foreach vis_start vis
}
service_triggers() {
procd_add_reload_trigger "vis"
procd_open_trigger
procd_add_raw_trigger "interface.*" 1000 /etc/init.d/vis reload
procd_close_trigger
}