Initial.
This commit is contained in:
commit
c953c77786
4 changed files with 36 additions and 0 deletions
6
module.prop
Normal file
6
module.prop
Normal 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
6
service.sh
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/system/bin/sh
|
||||||
|
# -------------------------------------------------
|
||||||
|
# Magisk service script – starts the watchdog daemon
|
||||||
|
# -------------------------------------------------
|
||||||
|
|
||||||
|
nohup /system/bin/termux_watchdog >/dev/null 2>&1 &
|
||||||
24
system/bin/termux_watchdog
Normal file
24
system/bin/termux_watchdog
Normal 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
BIN
termux-watchdog.zip
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue