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