complete refactor

This commit is contained in:
Technomancer 2023-12-26 17:03:52 -06:00
parent 9f5175bd1b
commit b43f1ad1dd
No known key found for this signature in database
GPG Key ID: 33A12B0480AFC8E9

View File

@ -9,7 +9,35 @@ with open("conf.json", "r") as file:
# yeah yeah i should probably use YAML but i don't really want to fool with it rn lol -64 # yeah yeah i should probably use YAML but i don't really want to fool with it rn lol -64
sshc = paramiko.client.SSHClient() sshc = paramiko.client.SSHClient()
sshc.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # so we don't get whined at and crash over a unrecognized host-key healthstatus = ""
healthpassing = True
# define sshc so we don't have to type the whole thing every time we want a client as well as set our healthpassing variable
def healthcheck():
global healthstatus
response = os.system("ping -c 2 " + cfg["server"])
if response != 0:
healthstatus = "err"
else:
healthstatus = "ok"
def deploy():
# deployment shit here
sshc.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # so we don't get whined at and crash over a unrecognized host-key
sshc.connect(cfg["server"],port=cfg["port"],password=cfg["ssh-password"])
while True:
healthcheck()
if healthstatus != "ok":
print(healthstatus)
print("ONT is not responding!! Did we lose network connection, or is the ONT rebooting? Waiting for a successful ping then deploying!")
healthpassing = False
while healthpassing == False:
if healthcheck() == "ok":
print("ONT responded, deploying payload!")
healthpassing == True;
else:
print(healthstatus)
sshc.connect(cfg["server"],port=cfg["port"],password=cfg["ssh-password"])
sshc.exec_command("wall it works!!!")