forked from IDeletedSystem64/iptables-deploy
complete refactor
This commit is contained in:
parent
9f5175bd1b
commit
b43f1ad1dd
34
deploy.py
34
deploy.py
@ -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
|
||||
|
||||
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!!!")
|
Loading…
x
Reference in New Issue
Block a user