rewrite restart logic
This commit is contained in:
+14
-15
@@ -5,9 +5,6 @@ MODDIR=${0%/*}
|
||||
# load variables
|
||||
. $MODDIR/vars.sh
|
||||
|
||||
# LD_LIBRARY_PATH for NDK
|
||||
export LD_LIBRARY_PATH=/system/lib64:/data/adb/zerotier/lib
|
||||
|
||||
log_cli() {
|
||||
echo -e "$1" >> $ZTROOT/run/cli.out
|
||||
}
|
||||
@@ -29,33 +26,35 @@ _stop() {
|
||||
return
|
||||
fi
|
||||
|
||||
wait
|
||||
sleep 1 # sometimes it fails without sleeping
|
||||
|
||||
log "stopped zerotier-one"
|
||||
}
|
||||
_start() {
|
||||
if pid=`pidof zerotier-one`; then
|
||||
log "zerotier-one already running pid $pid"
|
||||
if pidof zerotier-one > /dev/null; then
|
||||
log "zerotier-one already running"
|
||||
else
|
||||
$ZTROOT/zerotier-one -d >> $ZT_LOG 2>&1 &
|
||||
pid=`pidof zerotier-one`
|
||||
log "started zerotier-one pid $pid"
|
||||
__start
|
||||
log "started zerotier-one"
|
||||
fi
|
||||
}
|
||||
_status() {
|
||||
# fake systemd lol
|
||||
if pid=`pidof zerotier-one`; then
|
||||
read pid < $ZTROOT/home/zerotier-one.pid
|
||||
|
||||
if pidof zerotier-one > /dev/null; then
|
||||
log_cli "\033[32m●\033[0m zerotier-one.service - ZeroTier One - Global Area Networking"
|
||||
log_cli " Active: \033[32mactive (running)\033[0m"
|
||||
log_cli " Main PID: $pid (zerotier-one)"
|
||||
else
|
||||
read pid_ < $ZTROOT/home/zerotier-one.pid
|
||||
log_cli "○ zerotier-one.service - ZeroTier One - Global Area Networking"
|
||||
log_cli " Active: inactive (dead)"
|
||||
log_cli " Main PID: $pid_ (code=exited)"
|
||||
log_cli " Main PID: $pid (code=exited)"
|
||||
fi
|
||||
}
|
||||
_restart() {
|
||||
_stop
|
||||
__start
|
||||
log "started zerotier-one"
|
||||
}
|
||||
|
||||
# ----------------------------------------------
|
||||
# call from inotifyd
|
||||
@@ -68,7 +67,7 @@ if [[ $# == 2 && "$1" == "w" ]]; then
|
||||
case "$cmd" in
|
||||
"start") _start;;
|
||||
"stop") _stop;;
|
||||
"restart") _stop; _start;;
|
||||
"restart") _restart;;
|
||||
"status") _status;;
|
||||
*) log "unknown command $cmd";;
|
||||
esac
|
||||
|
||||
+1
-4
@@ -37,11 +37,8 @@ mkdir -p $ZTROOT/run
|
||||
ip rule add from all lookup main pref 1
|
||||
ip -6 rule add from all lookup main pref 1
|
||||
|
||||
# LD_LIBRARY_PATH for NDK
|
||||
export LD_LIBRARY_PATH=$ZTROOT/lib
|
||||
|
||||
# start zerotier
|
||||
$ZTROOT/zerotier-one -d >> $ZT_LOG 2>&1 &
|
||||
__start
|
||||
|
||||
# ----------------------------------------------
|
||||
# CLI before login
|
||||
|
||||
+8
-1
@@ -9,4 +9,11 @@ DAEMON_LOG=$ZTROOT/run/daemon.log
|
||||
PIPE_CLI=$ZTROOT/run/pipe
|
||||
PIPE_APP=$APPROOT/run/pipe
|
||||
|
||||
BB=/data/adb/magisk/busybox
|
||||
BB=/data/adb/magisk/busybox
|
||||
|
||||
# LD_LIBRARY_PATH for NDK
|
||||
export LD_LIBRARY_PATH=/system/lib64:/data/adb/zerotier/lib
|
||||
|
||||
__start() {
|
||||
nohup $ZTROOT/zerotier-one -d &>> $ZT_LOG &
|
||||
}
|
||||
Reference in New Issue
Block a user