From 3e646d19b05d98a98c0414753d08a4c5cdf772dd Mon Sep 17 00:00:00 2001 From: binhex Date: Fri, 28 Jun 2024 16:19:21 +0100 Subject: [PATCH] include socks support --- run/nobody/watchdog.sh | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/run/nobody/watchdog.sh b/run/nobody/watchdog.sh index 2d123e1..be1eab6 100644 --- a/run/nobody/watchdog.sh +++ b/run/nobody/watchdog.sh @@ -44,6 +44,44 @@ while true; do fi + if [[ "${ENABLE_SOCKS}" == "yes" ]]; then + + # get current bind ip for microsocks, if different to vpn_ip then kill + microsocks_current_bind_ip=$(pgrep -fa 'microsocks' | grep -o -P -m 1 '(?<=-b\s)[\d\.]+') + + if [[ "${microsocks_current_bind_ip}" != "${vpn_ip}" ]]; then + + echo "[info] Restarting microsocks due to change in vpn ip..." + pkill -SIGTERM "microsocks" + + # run script to start microsocks + source /home/nobody/microsocks.sh + + else + + # check if microsocks is running, if not then skip shutdown of process + if ! pgrep -fa "/usr/local/bin/microsocks" > /dev/null; then + + echo "[info] microsocks not running" + + else + + # mark microsocks as running + microsocks_running="true" + + fi + + if [[ "${microsocks_running}" == "false" ]]; then + + # run script to start microsocks + source /home/nobody/microsocks.sh + + fi + + fi + + fi + if [[ "${sabnzbd_running}" == "false" ]]; then # run script to start sabnzbd @@ -95,6 +133,20 @@ while true; do fi + if [[ "${ENABLE_SOCKS}" == "yes" ]]; then + + # check if microsocks is running, if not then start via microsocks.sh + if ! pgrep -fa "/usr/local/bin/microsocks" > /dev/null; then + + echo "[info] microsocks not running" + + # run script to start microsocks + source /home/nobody/microsocks.sh + + fi + + fi + fi if [[ "${DEBUG}" == "true" && "${VPN_ENABLED}" == "yes" ]]; then