From df0b9824b04c72d0f4aa3fbf0fc98c523d154fee Mon Sep 17 00:00:00 2001 From: Mike Cifelli <1836280-mike-cifelli@users.noreply.gitlab.com> Date: Thu, 16 Sep 2021 16:28:20 -0400 Subject: [PATCH] Wait for network instead of sleeping --- wifi-keepalive.py | 3 --- wifi-keepalive.service | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/wifi-keepalive.py b/wifi-keepalive.py index 514f4dd..25f7e20 100644 --- a/wifi-keepalive.py +++ b/wifi-keepalive.py @@ -3,7 +3,6 @@ from subprocess import CalledProcessError, check_output from sys import exit from time import sleep -INITIAL_DELAY_IN_SECONDS = 40 PING_INTERVAL_IN_SECONDS = 80 @@ -11,7 +10,6 @@ class WifiKeepalive: def __init__(self): self.defaultRoute = None - self.initialDelay = INITIAL_DELAY_IN_SECONDS self.pingInterval = PING_INTERVAL_IN_SECONDS self.isConnected = False self.pingCommand = 'ping -c 1 -W 2 -n' @@ -26,7 +24,6 @@ class WifiKeepalive: sleep(self.pingInterval) def prepare(self): - sleep(self.initialDelay) self.updateDefaultWifiRoute() if self.defaultRoute: diff --git a/wifi-keepalive.service b/wifi-keepalive.service index d0e66ad..d703117 100644 --- a/wifi-keepalive.service +++ b/wifi-keepalive.service @@ -1,6 +1,7 @@ [Unit] Description=Wifi Keepalive Service -After=multi.user.target +Wants=network-online.target +After=network-online.target [Service] Type=simple