Browse Source

Fix process daemon startup bug

Mattraks 5 years ago
parent
commit
a7429ee23c
1 changed files with 6 additions and 7 deletions
  1. 6 7
      luci-app-ssr-plus/root/etc/init.d/shadowsocksr

+ 6 - 7
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -306,7 +306,8 @@ start_dns() {
 start_redir_tcp() {
 	local type=$(uci_get_by_name $GLOBAL_SERVER type)
 	local bin=$(find_bin $type)
-	[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") Main node:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && return 1
+	redir_tcp=1
+	[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") Main node:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && redir_tcp=0 && return 1
 	case "$(uci_get_by_name $GLOBAL_SERVER auth_enable)" in
 	1 | on | true | yes | enabled) ARG_OTA="-A" ;;
 	*) ARG_OTA="" ;;
@@ -374,9 +375,10 @@ start_redir_tcp() {
 
 start_redir_udp() {
 	if [ -n "$UDP_RELAY_SERVER" ]; then
+    redir_udp=1
 		local type=$(uci_get_by_name $UDP_RELAY_SERVER type)
 		local bin=$(find_bin $type)
-		[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") UDP TPROXY Relay:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && return 1
+		[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") UDP TPROXY Relay:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && redir_udp=0 && return 1
 		case "$type" in
 		ss | ssr)
 			case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in
@@ -480,12 +482,12 @@ start_local() {
 	[ "$local_server" == "same" ] && local_server=$GLOBAL_SERVER
 	local type=$(uci_get_by_name $local_server type)
 	local bin=$(find_bin $type)
-	[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") Global_Socks5:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && return 1
+	[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") Global_Socks5:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && local_enable=0 && return 1
 	case "$type" in
 	ss | ssr)
 		local name="Shadowsocks"
 		local bin=$(find_bin $type-local)
-		[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") Global_Socks5:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && return 1
+		[ ! -f "$bin" ] && echo "$(date "+%Y-%m-%d %H:%M:%S") Global_Socks5:Can't find $bin program, can't start!" >>/tmp/ssrplus.log && local_enable=0 && return 1
 		[ "$type" == "ssr" ] && name="ShadowsocksR"
 		gen_config_file $local_server 3 $(uci_get_by_type socks5_proxy local_port 1080)
 		$bin -c $CONFIG_SOCK5_FILE -u -f /var/run/ssr-local.pid >/dev/null 2>&1
@@ -668,14 +670,11 @@ start_rules() {
 rules() {
 	if [ "$GLOBAL_SERVER" == "nil" ]; then
 		return 1
-	else
-		redir_tcp=1
 	fi
 	mkdir -p /var/run /var/etc
 	run_mode=$(uci_get_by_type global run_mode)
 	UDP_RELAY_SERVER=$(uci_get_by_type global udp_relay_server)
 	[ "$UDP_RELAY_SERVER" == "same" ] && UDP_RELAY_SERVER=$GLOBAL_SERVER
-	[ -n "$UDP_RELAY_SERVER" ] && redir_udp=1
 	if start_rules; then
 		return 0
 	else