Added configuration file.

master
q3k 2013-04-08 13:04:44 +02:00
parent f2f361de62
commit c4ad992c50
3 changed files with 9 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import os
import time import time
import sys import sys
import subprocess import subprocess
import config
def _get_process_list(): def _get_process_list():
@ -15,7 +16,7 @@ def _get_process_list():
def _start_pppd(): 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() stdout, stderr = p.communicate()
if p.returncode != 0: if p.returncode != 0:
sys.stderr.write("Could not run pppd succesfully! Here is some debug data:\n") sys.stderr.write("Could not run pppd succesfully! Here is some debug data:\n")
@ -39,13 +40,13 @@ def _kill_pppd():
def _check_connectivity(): 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() p.communicate()
if p.returncode != 0: if p.returncode != 0:
sys.stderr.write("There seem to be some connectivity problems... Waiting 15 seconds, then giving it another shot...\n") sys.stderr.write("There seem to be some connectivity problems... Waiting 15 seconds, then giving it another shot...\n")
time.sleep(15) 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() p.communicate()
if p.returncode != 0: if p.returncode != 0:
sys.stderr.write("Connectivity problems persisting! :(\n") sys.stderr.write("Connectivity problems persisting! :(\n")

View File

@ -98,6 +98,4 @@ if __name__ == "__main__":
raise Exception("Could not doublefork! See logfile for details.") raise Exception("Could not doublefork! See logfile for details.")
sys.stderr.write("Daemon running! PID %i.\n" % os.getpid()) sys.stderr.write("Daemon running! PID %i.\n" % os.getpid())
while True: adsl.loop()
adsl.check()
time.sleep(60)

4
config.py.dist Normal file
View File

@ -0,0 +1,4 @@
PEER = "neozdrada"
PPPD = ["/usr/sbin/pppd", "call", PEER]
PING = ["/sbin/ping", "-W", "4", "-c", "1", "8.8.8.8"]