#/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()