Skip to content

Commit

Permalink
Add services check for XRay and Shadowsocks-Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Oct 2, 2023
1 parent 8746eaf commit cd69bc6
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion mptcp/files/usr/share/omr/post-tracking.d/010-services
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(pgrep -f omr-tracker-ss)" = "" ]
/etc/init.d/shadowsocks-libev restart 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/init.d/shadowsocks-rust ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f sslocal)" = "" ] && [ "$(pgrep -f sslocal)" = "" ] && [ "$(uci -q get shadowsocks-rust.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-rust.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-rust.sss0.server)" != "192.18.1.3" ] && [ "$(uci -q get shadowsocks-rust.sss0.key)" != "" ]; then
_log "Can't find Shadowsocks Rust, restart it..."
/etc/init.d/shadowsocks-rust restart 2>&1 >/dev/null
sleep 5
fi
if [ -f /etc/init.d/glorytun ] && [ "$(pgrep glorytun)" = "" ] && [ "$(uci -q get glorytun.vpn.enable)" = "1" ] && [ -f /etc/init.d/glorytun ] && [ "$(uci -q get glorytun.vpn.key)" != "" ]; then
_log "Can't find Glorytun, restart it..."
/etc/init.d/glorytun restart 2>&1 >/dev/null
Expand Down Expand Up @@ -63,6 +68,11 @@ if [ "$(pgrep -f v2ray)" = "" ] && [ "$(uci -q get v2ray.main.enabled)" = "1" ]
/etc/init.d/v2ray restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep -f xray)" = "" ] && [ "$(uci -q get xray.main.enabled)" = "1" ] && [ -f /etc/init.d/xray ]; then
_log "Can't find XRay, restart it..."
/etc/init.d/xray restart 2>&1 >/dev/null
sleep 5
fi
if [ "$(pgrep miniupnpd)" = "" ] && [ "$(uci -q get upnpd.config.enabled)" = "1" ] && [ -f /etc/init.d/miniupnpd ]; then
_log "Can't find miniupnpd, restart it..."
/etc/init.d/miniupnpd restart 2>&1 >/dev/null
Expand Down Expand Up @@ -95,13 +105,17 @@ if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ -f /etc/init.d/v2ray ] && [
_log "Can't find omr-tracker-v2ray, restart omr-tracker..."
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi
if [ "$(uci -q get xray.main.enabled)" = "1" ] && [ -f /etc/init.d/xray ] && [ "$(pgrep -f omr-tracker-xray)" = "" ] && [ "$(pgrep -f '/etc/init.d/omr-tracker')" = "" ]; then
_log "Can't find omr-tracker-xray, restart omr-tracker..."
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi

set_get_config() {
local server=$1
[ -n "$server" ] && uci -q set openmptcprouter.${server}.get_config=1
}

if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ]; then
if ([ -f /etc/init.d/shadowsocks-libev ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ]) || ([ -f /etc/init.d/shadowsocks-rust ] && [ "$(uci -q get shadowsocks-rust.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-rust.sss0.key)" = "" ] && [ "$(uci -q get shadowsocks-rust.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-rust.sss0.server)" != "192.18.1.3" ]); then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
Expand All @@ -112,6 +126,11 @@ if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(uci -q get shadowsocks-libev.sss
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi

if [ -f /etc/init.d/shadowsocks-rust ] && [ "$(uci -q get shadowsocks-rust.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-rust.sss0.key)" != "" ] && [ "$(uci -q get shadowsocks-rust.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.rust.server)" != "192.18.1.3" ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f '/etc/init.d/omr-tracker')" = "" ]; then
_log "Can't find omr-tracker-ss, restart omr-tracker..."
/etc/init.d/omr-tracker restart 2>&1 >/dev/null
fi

if [ "$(uci -q get glorytun.vpn.enable)" = "1" ] && [ "$(uci -q get glorytun.vpn.key)" = "" ]; then
config_load openmptcprouter
config_foreach set_get_config server
Expand All @@ -124,6 +143,12 @@ if [ "$(uci -q get v2ray.main.enabled)" = "1" ] && [ "$(uci -q get v2ray.omrout.
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi

if [ "$(uci -q get xray.main.enabled)" = "1" ] && [ "$(uci -q get xray.omrout.s_vless_user_id)" = "" ]; then
config_load openmptcprouter
config_foreach set_get_config server
[ -n "$(uci -q changes openmptcprouter)" ] && uci -q commit openmptcprouter
fi

if [ -n "$(logread | tail -n 2 | grep 'Ring expansion failed')" ]; then
_log "Workaround Ring expansion failed problem"
echo 1 > /sys/bus/pci/devices/0000:00:00.0/remove
Expand Down

0 comments on commit cd69bc6

Please sign in to comment.