update interaction

This commit is contained in:
eventlOwOp
2024-05-13 16:51:54 +08:00
parent 26fee1b1fa
commit b20a4e9ae9
2 changed files with 101 additions and 47 deletions
+38 -3
View File
@@ -1,13 +1,48 @@
#!/system/bin/sh
pipe=/data/adb/zerotier/run/pipe
temp_output=/data/adb/zerotier/run/temp.out
cli_output=/data/adb/zerotier/run/cli.out
cli_pid=/data/adb/zerotier/run/cli.pid
help_text="Usage: zerotier.sh {start|stop|restart|status}"
if [[ ! -p $pipe ]]; then
echo "daemon not running"
exit 1
fi
rm -f $cli_output
echo $$ > $cli_pid
on_receive() {
cat $cli_output
exit 0
}
run() {
echo $1 > $pipe
}
trap 'on_receive' SIGUSR1
if [[ "$1" ]]; then
echo "$1" > $pipe
if [[ "$2" ]]; then
echo $help_text
exit 1
fi
case "$1" in
"start") run $1;;
"stop") run $1;;
"restart") run $1;;
"status")) run $1;;
*)
echo "unknown command $1";;
esac
else
echo "Usage: zerotier.sh {start|stop|restart|join|leave}"
echo $help_text
exit 1
fi
sleep 10
echo "time out"
exit 1