diff --git a/adsl.py b/adsl.py index 213608f..3b43e93 100644 --- a/adsl.py +++ b/adsl.py @@ -2,6 +2,7 @@ import os import time import sys import subprocess +import config def _get_process_list(): @@ -15,7 +16,7 @@ def _get_process_list(): def _start_pppd(): - p = subprocess.Popen(["/usr/sbin/pppd", "call", "neozdrada"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(config.PPPD, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() if p.returncode != 0: sys.stderr.write("Could not run pppd succesfully! Here is some debug data:\n") @@ -39,13 +40,13 @@ def _kill_pppd(): def _check_connectivity(): - p = subprocess.Popen(["/sbin/ping", "-W", "4", "-c", "1", "8.8.8.8"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(config.PING, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.communicate() if p.returncode != 0: sys.stderr.write("There seem to be some connectivity problems... Waiting 15 seconds, then giving it another shot...\n") time.sleep(15) - p = subprocess.Popen(["/sbin/ping", "-W", "4", "-c", "1", "8.8.8.8"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(config.PING, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.communicate() if p.returncode != 0: sys.stderr.write("Connectivity problems persisting! :(\n") diff --git a/bouncer.py b/bouncer.py index 3a97f58..4817051 100644 --- a/bouncer.py +++ b/bouncer.py @@ -98,6 +98,4 @@ if __name__ == "__main__": raise Exception("Could not doublefork! See logfile for details.") sys.stderr.write("Daemon running! PID %i.\n" % os.getpid()) - while True: - adsl.check() - time.sleep(60) + adsl.loop() diff --git a/config.py.dist b/config.py.dist new file mode 100644 index 0000000..48db3a2 --- /dev/null +++ b/config.py.dist @@ -0,0 +1,4 @@ +PEER = "neozdrada" +PPPD = ["/usr/sbin/pppd", "call", PEER] + +PING = ["/sbin/ping", "-W", "4", "-c", "1", "8.8.8.8"]