coova-chilli: postpone startup until wan is available
authorThibaut VARÈNE <hacks@slashdirt.org>
Thu, 27 Jan 2022 10:28:15 +0000 (11:28 +0100)
committerRosen Penev <rosenp@gmail.com>
Sun, 30 Jan 2022 05:02:28 +0000 (21:02 -0800)
Coova Chilli will fail to start if e.g. it cannot resolve names in its
configuration (like uamserver, radiusserver, etc) which is typically the
case when wan is unavailable. Prevent this situation by delaying startup
if wan is not available.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
net/coova-chilli/files/chilli.init

index ab6ce7130c813ce54db45c3806444bc983cbb658..1c163a0d682733dc26ac8159f435c563a2e2fdbd 100644 (file)
@@ -52,19 +52,24 @@ start_chilli() {
        config_get_bool disabled "$1" 'disabled' 0
        [ $disabled = 1 ] && return
 
-       procd_open_instance "$cfg"
-       procd_set_param command /usr/sbin/chilli
-       procd_set_param file "$chilli_conf"
-       procd_append_param command \
-               --fg \
-               --conf "${base}.conf" \
-               --pidfile "${base}.pid" \
-               --cmdsocket "${base}.sock" \
-               --unixipc "${base}.ipc"
-       procd_set_param respawn
-       procd_set_param stdout 1
-       procd_set_param stderr 1
-       procd_close_instance
+       . /lib/functions/network.sh
+
+       local wanif ipaddr
+       if network_find_wan wanif && network_get_ipaddr ipaddr "$wanif"; then
+               procd_open_instance "$cfg"
+               procd_set_param command /usr/sbin/chilli
+               procd_set_param file "$chilli_conf"
+               procd_append_param command \
+                       --fg \
+                       --conf "${base}.conf" \
+                       --pidfile "${base}.pid" \
+                       --cmdsocket "${base}.sock" \
+                       --unixipc "${base}.ipc"
+               procd_set_param respawn
+               procd_set_param stdout 1
+               procd_set_param stderr 1
+               procd_close_instance
+       fi
 }
 
 start_service() {