update interaction
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user