Skip to content

Commit

Permalink
fix: restart service if no gateway is found (#13)
Browse files Browse the repository at this point in the history
This should fix #12
  • Loading branch information
fjpanag authored Nov 3, 2023
1 parent 7962a12 commit acc95f2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit acc95f2

Please sign in to comment.