From 823829688a3cb9a8e5c9697f2a180d8d0cf71fcb Mon Sep 17 00:00:00 2001 From: mrhotio <26902309+mrhotio@users.noreply.github.com> Date: Tue, 23 Jan 2024 07:23:29 +0100 Subject: [PATCH] put app specific code in seperate file --- root/app/proton_update_app | 8 ++++++++ root/etc/s6-overlay/s6-rc.d/service-proton/run | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 root/app/proton_update_app diff --git a/root/app/proton_update_app b/root/app/proton_update_app new file mode 100644 index 000000000..0a3ad49d5 --- /dev/null +++ b/root/app/proton_update_app @@ -0,0 +1,8 @@ +# shellcheck shell=bash +webui_https="http" +if grep -q 'WebUI\\HTTPS\\Enabled=true' "${CONFIG_DIR}/config/qBittorrent.conf"; then + webui_https="https" +fi +curl -fsSL --insecure -X POST -d "json={\"upnp\": false}" "${webui_https}://localhost:${WEBUI_PORTS%%/*}/api/v2/app/setPreferences" +curl -fsSL --insecure -X POST -d "json={\"random_port\": false}" "${webui_https}://localhost:${WEBUI_PORTS%%/*}/api/v2/app/setPreferences" +curl -fsSL --insecure -X POST -d "json={\"listen_port\": ${port}}" "${webui_https}://localhost:${WEBUI_PORTS%%/*}/api/v2/app/setPreferences" diff --git a/root/etc/s6-overlay/s6-rc.d/service-proton/run b/root/etc/s6-overlay/s6-rc.d/service-proton/run index 8e4500d7b..400034426 100644 --- a/root/etc/s6-overlay/s6-rc.d/service-proton/run +++ b/root/etc/s6-overlay/s6-rc.d/service-proton/run @@ -17,13 +17,8 @@ while true; do old_port=$(cat "${CONFIG_DIR}/forwarded_port") if [[ "${port}" != "${old_port}" ]]; then echo "${port}" > "${CONFIG_DIR}/forwarded_port" - webui_https="http" - if grep -q 'WebUI\\HTTPS\\Enabled=true' "${CONFIG_DIR}/config/qBittorrent.conf"; then - webui_https="https" - fi - curl -fsSL --insecure -X POST -d "json={\"upnp\": false}" "${webui_https}://localhost:${WEBUI_PORTS%%/*}/api/v2/app/setPreferences" - curl -fsSL --insecure -X POST -d "json={\"random_port\": false}" "${webui_https}://localhost:${WEBUI_PORTS%%/*}/api/v2/app/setPreferences" - curl -fsSL --insecure -X POST -d "json={\"listen_port\": ${port}}" "${webui_https}://localhost:${WEBUI_PORTS%%/*}/api/v2/app/setPreferences" + # shellcheck source=/dev/null + source "${APP_DIR}/proton_update_app" fi echo "[INFO] [$(date '+%Y-%m-%d %H:%M:%S')] ProtonVPN forwarded port is \"${port}\"." else