Added configuration file.
parent
f2f361de62
commit
c4ad992c50
7
adsl.py
7
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")
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
PEER = "neozdrada"
|
||||
PPPD = ["/usr/sbin/pppd", "call", PEER]
|
||||
|
||||
PING = ["/sbin/ping", "-W", "4", "-c", "1", "8.8.8.8"]
|
Loading…
Reference in New Issue