From 7561ee1dfea3f0641440f02a3eb8bcee11499627 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 8 Aug 2024 20:53:32 +0200 Subject: [PATCH] Move unbound check before dnsmasq and add more tries --- .../usr/share/omr/schedule.d/010-services | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/omr-schedule/files/usr/share/omr/schedule.d/010-services b/omr-schedule/files/usr/share/omr/schedule.d/010-services index 4a389f10d..830c41d90 100755 --- a/omr-schedule/files/usr/share/omr/schedule.d/010-services +++ b/omr-schedule/files/usr/share/omr/schedule.d/010-services @@ -28,28 +28,29 @@ if [ -f /etc/init.d/glorytun-udp ] && [ "$(pgrep glorytun-udp)" = "" ] && [ "$(u sleep 5 fi +if [ -f /etc/init.d/unbound ] && [ "$(uci -q get unbound.@unbound[0].enabled)" = "1" ] && [ -n "$(uci -q get dnsmasq1.server | grep 127.0.0.1#5353)" ]; then + if [ "$(pgrep -f unbound)" = "" ]; then + _log "Can't find unbound, restart it..." + /etc/init.d/unbound restart >/dev/null 2>&1 + sleep 5 + elif [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ] && [ "$(uci -q get unbound.ub_main.listen_port)" = "5353" ] && [ -n "$(dig +timeout=4 +tries=2 openmptcprouter.com -p 5353 | grep 'ANSWER: 0')" ]; then + _log "Can't resolve via unbound, restart it..." + /etc/init.d/unbound restart >/dev/null 2>&1 + sleep 5 + fi +fi + if [ -f /etc/init.d/dnsmasq ]; then if [ "$(pgrep -f dnsmasq)" = "" ]; then _log "Can't find dnsmasq, restart it..." /etc/init.d/dnsmasq restart >/dev/null 2>&1 sleep 5 - elif [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ] && [ -n "$(dig +timeout=4 +tries=1 openmptcprouter.com 2>&1 | grep -i 'connection refused')" ]; then + elif [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ] && [ -n "$(dig +timeout=4 +tries=2 openmptcprouter.com 2>&1 | grep -i 'connection refused')" ]; then _log "Can't resolve via dnsmasq, restart it..." /etc/init.d/dnsmasq restart >/dev/null 2>&1 sleep 5 fi fi -if [ -f /etc/init.d/unbound ] && [ "$(uci -q get unbound.@unbound[0].enabled)" = "1" ]; then - if [ "$(pgrep -f unbound)" = "" ]; then - _log "Can't find unbound, restart it..." - /etc/init.d/unbound restart >/dev/null 2>&1 - sleep 5 - elif [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ] && [ "$(uci -q get unbound.ub_main.listen_port)" = "5353" ] && [ -n "$(dig +timeout=4 +tries=1 openmptcprouter.com -p 5353 | grep 'ANSWER: 0')" ]; then - _log "Can't resolve via unbound, restart it..." - /etc/init.d/unbound restart >/dev/null 2>&1 - sleep 5 - fi -fi if [ "$(pgrep openvpn)" = "" ] && [ -f /etc/init.d/openvpn ]; then openvpn_enable=0