Compare commits
No commits in common. "9f73b025172f2a591f4991d69e67057e1cc6bea5" and "45ff74708a626d8abba5faddbc7f2857209f1dbe" have entirely different histories.
9f73b02517
...
45ff74708a
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
conf.json
|
|
||||||
.vscode
|
|
@ -1,3 +1,3 @@
|
|||||||
# iptables-deploy
|
# iptables-deploy
|
||||||
|
|
||||||
A python script to monitor and automatically deploy a bash script that sets iptables rules when it sees the ONT go offline then back online.
|
A python script to monitor and automatically deploy a bash script that sets iptables rules when it sees an the offline and back online.
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"server": "",
|
|
||||||
"port": "",
|
|
||||||
"payload": "payload/payload.sh",
|
|
||||||
"ssh-user": "",
|
|
||||||
"ssh-password": "",
|
|
||||||
"ssh-key": ""
|
|
||||||
}
|
|
52
deploy.py
52
deploy.py
@ -1,52 +0,0 @@
|
|||||||
import paramiko
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import time # i need time to get this done
|
|
||||||
|
|
||||||
# import modules
|
|
||||||
|
|
||||||
with open("conf.json", "r") as file:
|
|
||||||
cfg = json.load(file)
|
|
||||||
# open the config file and make it accessible via "cfg"
|
|
||||||
|
|
||||||
sshc = paramiko.client.SSHClient()
|
|
||||||
healthstatus = "" # possible values: "ok", "err"
|
|
||||||
healthpassing = True
|
|
||||||
# set our variables
|
|
||||||
|
|
||||||
def healthcheck():
|
|
||||||
global healthstatus
|
|
||||||
response = os.system("ping -c 2 " + cfg["server"] + ">> /dev/null")
|
|
||||||
if response != 0:
|
|
||||||
healthstatus = "err"
|
|
||||||
else:
|
|
||||||
healthstatus = "ok"
|
|
||||||
|
|
||||||
def deploy():
|
|
||||||
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"],key_filename=cfg["ssh-key"])
|
|
||||||
|
|
||||||
sftp = sshc.open_sftp() # after opening the ssh connection, we'll open a sftp connection.
|
|
||||||
sftp.put("./payload/payload.sh", "/payload.sh") # upload the payload via SFTP.
|
|
||||||
|
|
||||||
sshc.exec_command("chmod +x $HOME/payload.sh") # make it executable
|
|
||||||
sshc.exec_command("./payload.sh") # and finally, run the payload.
|
|
||||||
sshc.close # close the connection.
|
|
||||||
while True:
|
|
||||||
healthcheck()
|
|
||||||
|
|
||||||
if healthstatus != "ok":
|
|
||||||
print("ONT is not responding!! Did we lose network connection, or is the ONT rebooting? waiting for ONT to respond, then deploying payload!")
|
|
||||||
healthpassing = False
|
|
||||||
while healthpassing == False:
|
|
||||||
print("Checking for a response...")
|
|
||||||
healthcheck()
|
|
||||||
|
|
||||||
if healthstatus == "ok":
|
|
||||||
print("ONT responded, deploying payload!")
|
|
||||||
healthpassing == True;
|
|
||||||
deploy()
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print("Got a response! health status is ok.")
|
|
||||||
time.sleep(30) # we will run this loop every 30 seconds so we don't pelt the poor thing in pings.
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
wall "it works!!"
|
|
@ -1,93 +0,0 @@
|
|||||||
appdirs==1.4.4
|
|
||||||
argcomplete==2.0.0
|
|
||||||
bcrypt==4.1.2
|
|
||||||
beautifulsoup4==4.12.2
|
|
||||||
blivet==3.7.1
|
|
||||||
blivet-gui==2.4.2
|
|
||||||
Brlapi==0.8.4
|
|
||||||
Brotli==1.0.9
|
|
||||||
certifi==2022.9.24
|
|
||||||
cffi==1.15.1
|
|
||||||
chardet==5.2.0
|
|
||||||
charset-normalizer==3.1.0
|
|
||||||
click==8.1.3
|
|
||||||
cryptography==41.0.7
|
|
||||||
cssselect==1.1.0
|
|
||||||
cupshelpers==1.0
|
|
||||||
dasbus==1.7
|
|
||||||
dbus-python==1.3.2
|
|
||||||
decorator==5.1.1
|
|
||||||
Deprecated==1.2.14
|
|
||||||
distro==1.8.0
|
|
||||||
dnf==4.18.2
|
|
||||||
docopt==0.6.2
|
|
||||||
evdev==1.6.1
|
|
||||||
fedora-third-party==0.10
|
|
||||||
file-magic==0.4.0
|
|
||||||
gpg==1.17.1
|
|
||||||
humanize==3.13.1
|
|
||||||
idna==3.4
|
|
||||||
initial-setup==0.3.97
|
|
||||||
invoke==2.2.0
|
|
||||||
Jinja2==3.0.3
|
|
||||||
langtable==0.0.64
|
|
||||||
libcomps==0.1.20
|
|
||||||
libdnf==0.72.0
|
|
||||||
libvirt-python==9.0.0
|
|
||||||
lxml==4.9.2
|
|
||||||
MarkupSafe==2.1.2
|
|
||||||
mutagen==1.46.0
|
|
||||||
nftables==0.1
|
|
||||||
numpy==1.24.4
|
|
||||||
olefile==0.46
|
|
||||||
packaging==23.0
|
|
||||||
paramiko==3.4.0
|
|
||||||
pexpect==4.8.0
|
|
||||||
pid==2.2.3
|
|
||||||
Pillow==9.5.0
|
|
||||||
ply==3.11
|
|
||||||
productmd==1.37
|
|
||||||
protonvpn-cli==2.2.11
|
|
||||||
ptyprocess==0.7.0
|
|
||||||
pwquality==1.4.5
|
|
||||||
pycairo==1.23.0
|
|
||||||
pycparser==2.20
|
|
||||||
pycryptodomex==3.19.0
|
|
||||||
pycups==2.0.1
|
|
||||||
pycurl==7.45.2
|
|
||||||
pyenchant==3.2.2
|
|
||||||
PyGObject==3.44.2
|
|
||||||
pykickstart==3.47
|
|
||||||
PyNaCl==1.5.0
|
|
||||||
pyparted==3.12.0
|
|
||||||
PyQt5==5.15.9
|
|
||||||
PyQt5-sip==12.11.1
|
|
||||||
PySocks==1.7.1
|
|
||||||
python-augeas==1.1.0
|
|
||||||
python-dateutil==2.8.2
|
|
||||||
python-gettext==4.0
|
|
||||||
python-manatools==0.0.4
|
|
||||||
python-meh==0.51
|
|
||||||
pythondialog==3.5.3
|
|
||||||
pyudev==0.24.0
|
|
||||||
pyxdg==0.27
|
|
||||||
PyYAML==6.0
|
|
||||||
regex==2023.10.3
|
|
||||||
requests==2.28.2
|
|
||||||
requests-file==1.5.1
|
|
||||||
requests-ftp==0.3.1
|
|
||||||
rpm==4.18.2
|
|
||||||
scour==0.38.2
|
|
||||||
selinux==3.5
|
|
||||||
sepolicy==3.5
|
|
||||||
setools==4.4.3
|
|
||||||
simpleaudio==1.0.4
|
|
||||||
simpleline==1.9.0
|
|
||||||
six==1.16.0
|
|
||||||
sos==4.5.1
|
|
||||||
soupsieve==2.4.1
|
|
||||||
systemd-python==235
|
|
||||||
urllib3==1.26.18
|
|
||||||
websockets==10.4
|
|
||||||
wrapt==1.16.0
|
|
||||||
yt-dlp==2023.10.7
|
|
Loading…
x
Reference in New Issue
Block a user