forked from IDeletedSystem64/iptables-deploy
		
	complete refactor
This commit is contained in:
		
							
								
								
									
										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
 | 
					# 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sshc.connect(cfg["server"],port=cfg["port"],password=cfg["ssh-password"])
 | 
					def healthcheck(): 
 | 
				
			||||||
sshc.exec_command("wall it works!!!")
 | 
					    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)
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user