bitwarden

This commit is contained in:
jaydee
2024-11-29 12:01:41 +01:00
parent f24fd3db6d
commit b06c1cca44

View File

@@ -9,12 +9,21 @@ import subprocess
import sys
import os
import platform
from wakeonlan import send_magic_packet
pid = os.getpid()
host = platform.node().lower()
cmnd = "ps -ef|grep omv_backups.py|grep -v grep |grep -v {}|wc -l".format(pid)
status, output = subprocess.getstatusoutput(cmnd)
def is_port_open(host, port):
try:
sock = socket.create_connection((host, port))
sock.close()
return True
except socket.error:
return False
print(output)
if int(output) > 0:
print("Running already!")
@@ -83,16 +92,32 @@ if not host in backups:
print(f"No backup jobs for {host}")
sys.exit()
print("Test connection")
try:
hm = socket.gethostbyaddr("omv.home.lan")
hm = socket.gethostbyaddr("omv.home.lan")
HOST_UP = os.system(f"ping -c 1 -w 2 omv.home.lan") == 0
print(HOST_UP)
if not HOST_UP:
print("Backup host down")
send_magic_packet('88:c9:b3:b5:23:d8')
hostdown = True
while hostdown:
HOST_UP = os.system(f"ping -c 1 -w 2 omv.home.lan") == 0
print(HOST_UP)
if not HOST_UP:
print("Backup host down")
sys.exit()
except socket.herror:
print("Unknown host")
print("Backup host down, waiting")
time.sleep(5)
else:
print("host up")
hostdown = False
host = "omv.home.lan"
port = 22 # Replace with the port you want to test
if is_port_open(host, port):
print(f"Port {port} on {host} is open.")
else:
print(f"Port {port} on {host} is closed.")
sys.exit()
for b in backups[host]:
topic = "sectorq/omv/backups/{}".format(b.lower())