aboutsummaryrefslogtreecommitdiff
path: root/pykeepalive.py
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-09-28 19:30:41 +0200
committerneodarz <neodarz@neodarz.net>2019-09-28 19:30:41 +0200
commitd70390197ee3e06ee1fecbc14d1ed48ba4040c94 (patch)
tree325267c8d64ed2d7282d1d3166b0a651b9594ddc /pykeepalive.py
downloadpykeepalive-master.tar.xz
pykeepalive-master.zip
Initial commitHEADmaster
Diffstat (limited to 'pykeepalive.py')
-rw-r--r--pykeepalive.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/pykeepalive.py b/pykeepalive.py
new file mode 100644
index 0000000..e4d54af
--- /dev/null
+++ b/pykeepalive.py
@@ -0,0 +1,42 @@
+#/bin/python3
+
+import sys, time
+import tailhead
+
+from config import *
+
+import tools
+import commands
+import file
+import log
+
+if len(sys.argv) == 1:
+ log.tail_log()
+ if commands.multi_ping(HOSTS, INTERFACE) == 0:
+ file.log_write("ONLINE")
+ else:
+ print("Ooops, we're offline!")
+ file.log_write("OFFLINE >> RESETING INTERFACE [{}]".format(INTERFACE))
+ print(">> Reseting interface [{}]...".format(INTERFACE))
+ ip, gateway, subnet = commands.uqmi_current_settings()
+ commands.ifconfig_update(INTERFACE, ip, subnet)
+ commands.route_update(gateway)
+elif len(sys.argv) == 2:
+ if sys.argv[1] == "tail":
+ log.tail_log()
+ for line in tailhead.follow_path(LOG_PATH_FILE):
+ if line is not None:
+ print(tools.status_color(line))
+ else:
+ time.sleep(1)
+ elif sys.argv[1] == "cat":
+ log.tail_log()
+ with open(LOG_PATH_FILE) as f:
+ for line in f:
+ print(tools.status_color(line), end="")
+ else:
+ tools.show_help()
+else:
+ tools.show_help()
+
+