This commit is contained in:
天クマ 2025-12-09 21:05:39 -03:00
commit c953c77786
4 changed files with 36 additions and 0 deletions

6
module.prop Normal file
View file

@ -0,0 +1,6 @@
id=termux-watchdog
name=Termux Watchdog
version=1.0
versionCode=1
author=tenkuma
description=Reboots the device when the Termux app disappears.

6
service.sh Normal file
View file

@ -0,0 +1,6 @@
#!/system/bin/sh
# -------------------------------------------------
# Magisk service script starts the watchdog daemon
# -------------------------------------------------
nohup /system/bin/termux_watchdog >/dev/null 2>&1 &

View file

@ -0,0 +1,24 @@
#!/system/bin/sh
LOG="/data/local/tmp/termux_watchdog.log"
echo "$(date): Watchdog launched (PID=$)" >> "$LOG"
# ---------- Wait for Termux ----------
while true; do
TERMUX_PID=$(pidof -s com.termux)
if [ -n "$TERMUX_PID" ]; then
echo "$(date): Detected Termux (PID=$TERMUX_PID)" >> "$LOG"
break
fi
sleep 5
done
# ---------- Monitor ----------
while true; do
TERMUX_PID=$(pidof -s com.termux)
if [ -z "$TERMUX_PID" ]; then
echo "$(date): Termux no longer running -> reboot" >> "$LOG"
reboot
break
fi
sleep 5
done

BIN
termux-watchdog.zip Normal file

Binary file not shown.