0
0
mirror of https://github.com/openwrt/packages.git synced 2025-02-12 02:21:14 +00:00
packages/net/dawn/files/dawn.init
Nick Hainke c1490175d3 dawn: respawn dawn in case of crash
Some users report that DAWN sometimes crashes after a while. Mostly
this happens after the new update has been rolled out.

Since I would not like to go back to the older version, I add as
a workaround for now that DAWN automatically respawned.

Workaround for:
https://github.com/berlin-open-wireless-lab/DAWN/issues/151

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-10-21 11:25:10 +02:00

68 lines
1.1 KiB
Bash
Executable File

#!/bin/sh /etc/rc.common
USE_PROCD=1
START=81
STOP=81
PROG=/usr/sbin/dawn
NAME=dawn
wait_for_network()
{
ubus -t 15 wait_for network.interface.$1 2>/dev/null
}
boot()
{
ubus -t 5 wait_for umdns 2>/dev/null
config_load network
config_foreach wait_for_network interface
rc_procd start_service
}
reload_service()
{
if service_running; then
ubus call dawn reload_config
else
start
fi
}
service_triggers()
{
procd_add_reload_trigger "dawn"
}
start_service()
{
local _tcp_buffer
local _network_option
config_load dawn
load_tcp_config() {
config_get _tcp_buffer "$1" tcp_port
config_get _network_option "$1" network_option
}
config_foreach load_tcp_config network
touch /tmp/dawn_mac_list
echo "Starting Service..."
procd_open_instance
procd_set_param command $PROG
procd_set_param respawn 3600 15 0
procd_set_param stdout 0 # here it is possible to remove the debug output...
procd_set_param stderr 1
if [ ${_network_option} -eq 2 ]; then
procd_add_mdns "dawn" "tcp" "${_tcp_buffer}"
echo "UMDNS with port ${_tcp_buffer}"
fi
procd_close_instance
echo "Dawn instance started!"
}