diff --git a/libs/core.sh b/libs/core.sh index 326a85d..5595fa5 100755 --- a/libs/core.sh +++ b/libs/core.sh @@ -108,6 +108,15 @@ function get_def_gw { if [ "$(cat /sys/class/net/wlan0/operstate)" == "up" ]; then default_gw="$(ip route | awk 'NR==1 {print $3}')" echo "${default_gw}" + if [ -z "$default_gw" ]; then + log_msg "WARN: Cannot get the default gateway. Restarting service..." + sleep 5 + systemctl restart sonar.service + fi + else + log_msg "WARN: Network is not ready yet. Restarting service..." + sleep 5 + systemctl restart sonar.service fi }