add scripts

This commit is contained in:
Pakin 2025-08-25 13:43:03 +07:00
parent f2f9f6a2d1
commit d43498b0bb
4 changed files with 45 additions and 0 deletions

2
pack.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
zip adbdguard.zip start.sh status.sh stop.sh adbdguard.json target/aarch64-linux-android/release/adbdguard

22
start.sh Normal file
View file

@ -0,0 +1,22 @@
#!/system/bin/sh
set -eu
BASE=/data/local/adbdguard
BIN="$BASE/bin/adbdguard"
CFG="$BASE/adbdguard.json"
LOG=/data/local/tmp/adbdguard.log
PIDF=/dev/adbdguard.pid
# already running?
if [ -e "$PIDF" ] && kill -0 "$(cat "$PIDF")" 2>/dev/null; then
echo "running: $(cat "$PIDF")"
exit 0
fi
# perms
chmod 755 "$BIN"
[ -f "$CFG" ] || echo '{}' > "$CFG"
# start
"$BIN" --config "$CFG" >> "$LOG" 2>&1 &
echo $! > "$PIDF"
echo "started: $(cat "$PIDF")"

9
status.sh Normal file
View file

@ -0,0 +1,9 @@
#!/system/bin/sh
PIDF=/dev/adbdguard.pid
if [ -e "$PIDF" ] && kill -0 "$(cat "$PIDF")" 2>/dev/null; then
echo "running: $(cat "$PIDF")"
exit 0
fi
echo "stopped"
exit 1

12
stop.sh Normal file
View file

@ -0,0 +1,12 @@
#!/system/bin/sh
set -eu
if [ -e "$PIDF" ]; then
PID=$(cat "$PIDF")
if kill -0 "$PID" 2>/dev/null; then
kill "$PID"
echo "stopping $PID"
fi
rm -f "$PIDF"
else
echo "not running"
fi