routing/olsrd/files/olsrd4.init
Nick Hainke 5311c844b6 olsrd: fix olsrd starting before network
Should fix #691.

Sometimes the wifi interface is not ready before olsrd tries to access
it. This leads to warnings in the form of:

daemon.info olsrd: /etc/rc.d/S65olsrd: olsrd_write_interface()
	Warning: Interface 'wireless0' not found, skipped
daemon.notice procd: /etc/rc.d/S65olsrd: olsrd: /etc/rc.d/S65olsrd:
	olsrd_write_interface() Warning: Interface 'wireless0' not found,			skipped

We make use of the "wait_for" procd command that allows us to wait for
the network before starting olsrd.

Tested-by: Noki
Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-07-07 14:49:23 +02:00

55 lines
1.1 KiB
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2013 OpenWrt.org
. $IPKG_INSTROOT/lib/functions/olsrd.sh
START=65
USE_PROCD=1
BIN=/usr/sbin/olsrd
OLSRD=olsrd
CONF=/var/etc/$OLSRD.conf
PID=/var/run/olsrd.pid
wait_for_network()
{
ubus -t 15 wait_for network.interface.$1 2>/dev/null
}
boot()
{
config_load network
config_foreach wait_for_network interface
rc_procd start_service
}
start_service() {
olsrd_generate_config $OLSRD
procd_open_instance
procd_set_param command "$BIN"
procd_append_param command -f ${CONF}
procd_append_param command -nofork
procd_append_param command -pidfile ${PID}
# restart if olsrd dies
procd_set_param respawn
# automatically restart olsrd if generated cfg has changed
procd_set_param file $CONF
procd_set_param pidfile $PID
procd_close_instance
olsrd_setup_smartgw_rules
}
service_triggers() {
# reload if config changed via uci
procd_add_reload_trigger "olsrd"
# restart on ifup interface events
for n in $(olsrd_list_configured_interfaces $OLSRD); do
procd_add_reload_interface_trigger $n /etc/init.d/$OLSRD reload
done
}