mirror of
https://gitlab.sectorq.eu/jaydee/omv_backup.git
synced 2025-07-01 23:58:33 +02:00
added switch off
This commit is contained in:
@ -130,10 +130,9 @@ hostdown = True
|
|||||||
n=0
|
n=0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = {"camera":"door_camera"}
|
url = "http://m-server.home.lan:8123/api/webhook/-0eWYFhSTzdusAO8jwQS9t1AT?mode=on"
|
||||||
url = "http://m-server.home.lan:8123/api/webhook/-0eWYFhSTzdusAO8jwQS9t1AT"
|
|
||||||
|
|
||||||
x = requests.post(url, data)
|
x = requests.post(url)
|
||||||
|
|
||||||
print(x.text)
|
print(x.text)
|
||||||
except:
|
except:
|
||||||
@ -429,5 +428,34 @@ if _BACKUP:
|
|||||||
client.disconnect()
|
client.disconnect()
|
||||||
|
|
||||||
if _MODE == "auto":
|
if _MODE == "auto":
|
||||||
|
hostup = True
|
||||||
cmnd = "ssh root@omv.home.lan 'systemctl suspend &'"
|
cmnd = "ssh root@omv.home.lan 'systemctl suspend &'"
|
||||||
status, output = subprocess.getstatusoutput(cmnd)
|
status, output = subprocess.getstatusoutput(cmnd)
|
||||||
|
while hostup:
|
||||||
|
#HOST_UP = os.system(f"ping -c 1 -w 2 omv.home.lan") == 0
|
||||||
|
cmnd = f"ping -c 1 -w 2 {BACKUP_HOST}"
|
||||||
|
status, output = subprocess.getstatusoutput(cmnd)
|
||||||
|
# print(status)
|
||||||
|
# print(output)
|
||||||
|
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
print(f"Backup host up, waiting - {n}\r", end="")
|
||||||
|
time.sleep(5)
|
||||||
|
n += 1
|
||||||
|
else:
|
||||||
|
print("Backup host down " )
|
||||||
|
hostup = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
url = "http://m-server.home.lan:8123/api/webhook/-0eWYFhSTzdusAO8jwQS9t1AT?mode=off"
|
||||||
|
|
||||||
|
x = requests.post(url)
|
||||||
|
|
||||||
|
print(x.text)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user