This commit is contained in:
2025-01-11 14:50:08 +01:00
parent 9b86632efc
commit f6efdcc56e

View File

@ -19,7 +19,9 @@ pid = os.getpid()
host = platform.node().lower() host = platform.node().lower()
cmnd = "ps -ef|grep omv_backups.py|grep -v grep |grep -v {}|wc -l".format(pid) cmnd = "ps -ef|grep omv_backups.py|grep -v grep |grep -v {}|wc -l".format(pid)
status, output = subprocess.getstatusoutput(cmnd) status, output = subprocess.getstatusoutput(cmnd)
if int(output) > 0:
print("Running already!")
sys.exit()
def is_port_open(host, port): def is_port_open(host, port):
try: try:
sock = socket.create_connection((host, port)) sock = socket.create_connection((host, port))
@ -29,13 +31,14 @@ def is_port_open(host, port):
return False return False
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# doesn't even have to be reachable # doesn't even have to be reachable
s.connect(('192.168.77.1', 1)) conn = False
IP = s.getsockname()[0] while not conn:
print(IP) s.connect(('192.168.77.1', 1))
print(output) IP = s.getsockname()[0]
if int(output) > 0: print(IP)
print("Running already!") print(output)
sys.exit() time.sleep(5)
broker = 'mqtt.home.lan' broker = 'mqtt.home.lan'
port = 1883 port = 1883
topic_sum = "sectorq/omv/backups" topic_sum = "sectorq/omv/backups"