optware: fix optware init script issue

This commit is contained in:
Nick Peng
2023-02-21 22:59:50 +08:00
parent 995d5dce95
commit a6cb6061ec

View File

@@ -343,28 +343,28 @@ case "$1" in
$SMARTDNS_BIN -c "$SMARTDNS_CONF" -p $SMARTDNS_PID $SMARTDNS_BIN -c "$SMARTDNS_CONF" -p $SMARTDNS_PID
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
clear_rule clear_rule
exit 1
fi fi
;; ;;
status) status)
pid="$(cat $SMARTDNS_PID |head -n 1 2>/dev/null)" pid="$(cat $SMARTDNS_PID |head -n 1 2>/dev/null)"
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
echo "smartdns not running." echo "smartdns not running."
return 0 exit 0
fi fi
if [ -d "/proc/$pid" ]; then if [ -d "/proc/$pid" ]; then
echo "smartdns running" echo "smartdns is running"
return 0; exit 0
fi fi
echo "smartdns not running." echo "smartdns not running."
return 0; exit 0
;; ;;
stop) stop)
clear_rule
pid="$(cat "$SMARTDNS_PID" | head -n 1 2>/dev/null)" pid="$(cat "$SMARTDNS_PID" | head -n 1 2>/dev/null)"
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
echo "smartdns not running." echo "smartdns not running."
return 0 exit 0
fi fi
kill -15 "$pid" 2>/dev/null kill -15 "$pid" 2>/dev/null
@@ -379,17 +379,17 @@ case "$1" in
do do
pid="$(cat "$SMARTDNS_PID" | head -n 1 2>/dev/null)" pid="$(cat "$SMARTDNS_PID" | head -n 1 2>/dev/null)"
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
return 0 break
fi fi
if [ ! -d "/proc/$pid" ]; then if [ ! -d "/proc/$pid" ]; then
return 0 break
fi fi
stat="$(cat /proc/${pid}/stat | awk '{print $3}' 2>/dev/null)" stat="$(cat /proc/${pid}/stat | awk '{print $3}' 2>/dev/null)"
if [ "$stat" = "Z" ]; then if [ "$stat" = "Z" ]; then
$SLEEP $SLEEPTIME $SLEEP $SLEEPTIME
return 0 break
fi fi
$SLEEP $SLEEPTIME 2>/dev/null $SLEEP $SLEEPTIME 2>/dev/null
@@ -397,11 +397,15 @@ case "$1" in
done done
kill -9 "$pid" 2>/dev/null kill -9 "$pid" 2>/dev/null
clear_rule
exit 0
;; ;;
restart) restart)
$0 stop $0 stop
$0 start $0 start
;; ;;
reload)
;;
enable) enable)
nvram set apps_state_enable=2 nvram set apps_state_enable=2
nvram set apps_state_error=0 nvram set apps_state_error=0