Wait for network instead of sleeping

This commit is contained in:
Mike Cifelli 2021-09-16 16:28:20 -04:00
parent be5d4176a3
commit df0b9824b0
2 changed files with 2 additions and 4 deletions

View File

@ -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:

View File

@ -1,6 +1,7 @@
[Unit]
Description=Wifi Keepalive Service
After=multi.user.target
Wants=network-online.target
After=network-online.target
[Service]
Type=simple