Fixing issues with latest version of qbittorrent (#1)
Continuous Integration / docker (push) Successful in 21s
Continuous Integration / docker (push) Successful in 21s
Reviewed-on: #1 Co-authored-by: Dawson <dawson@funkemunky.cc> Co-committed-by: Dawson <dawson@funkemunky.cc>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Load variables
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
GITEA_URL="${GITHUB_SERVER_URL}"
|
||||
REGISTRY="$(printf '%s\n' "$GITEA_URL" | sed -E 's#^https?://##; s#/$##')"
|
||||
REPO_FULL="${GITHUB_REPOSITORY}"
|
||||
|
||||
echo "GITEA_URL=$GITEA_URL"
|
||||
echo "REGISTRY=$REGISTRY"
|
||||
echo "REPO_FULL=$REPO_FULL"
|
||||
|
||||
{
|
||||
echo "GITEA_URL=$GITEA_URL"
|
||||
echo "REGISTRY=$REGISTRY"
|
||||
echo "REPO_FULL=$REPO_FULL"
|
||||
} >> "$GITHUB_ENV"
|
||||
- name: Behavior confirm
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Registry in env: ${{ env.REGISTRY }}"
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ vars.PACKAGE_USERNAME }}
|
||||
password: ${{ secrets.PACKAGE_SECRET }}
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.REGISTRY }}/${{ env.REPO_FULL }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=sha,prefix=
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
@@ -17,4 +17,6 @@ Tools
|
||||
| `TZ` | `UTC` | `America/Denver` | Set your [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to make sure logs rotate at local midnight instead of at UTC midnight.
|
||||
| `WIREGUARD_INTERFACE` | `wg0` | `wg0`, `wg1`, ... | Set the wireguard interface name to use.
|
||||
| `LOCAL_IPV4_SUBNETS` | `192.168.0.0/16` | `192.168.0.0/16, 10.0.0.0/8` | Comma separated list of local subnet CIDRs to be allowed outside the wireguard tunnel.
|
||||
| `WEBUI_HOST` | `http://localhost:8080` | <URL to qBittorrent Web UI> | Url to the qBittorrent Web UI. Authenication must be disabled to localhost connections.
|
||||
| `WEBUI_HOST` | `http://localhost:8080` | <URL to qBittorrent Web UI> | URL to the qBittorrent Web UI. Authentication must be disabled to localhost connections unless `WEBUI_USERNAME` and `WEBUI_PASSWORD` are set.
|
||||
| `WEBUI_USERNAME` | | `admin` | Optional qBittorrent Web UI username. Use this if localhost authentication bypass is not enabled.
|
||||
| `WEBUI_PASSWORD` | | `adminadmin` | Optional qBittorrent Web UI password. Use this if localhost authentication bypass is not enabled.
|
||||
|
||||
+73
-8
@@ -98,10 +98,43 @@ wait ${!}
|
||||
|
||||
# qbittorrent webui host
|
||||
WEBUI_HOST="${WEBUI_HOST:-http://localhost:8080}"
|
||||
WEBUI_USERNAME="${WEBUI_USERNAME:-}"
|
||||
WEBUI_PASSWORD="${WEBUI_PASSWORD:-}"
|
||||
WEBUI_COOKIE_JAR="/tmp/qbittorrent-webui.$$.cookie"
|
||||
|
||||
qb_webui_curl() {
|
||||
curl \
|
||||
--silent \
|
||||
--show-error \
|
||||
--fail-with-body \
|
||||
--header "Referer: ${WEBUI_HOST}" \
|
||||
${WEBUI_COOKIE_ARGS+"${WEBUI_COOKIE_ARGS[@]}"} \
|
||||
"$@"
|
||||
}
|
||||
|
||||
# from this point on, its best effort, so just keep going and don't fail the container
|
||||
set +o errexit
|
||||
|
||||
if [[ -n "${WEBUI_USERNAME}" || -n "${WEBUI_PASSWORD}" ]]; then
|
||||
login_response=$(
|
||||
curl \
|
||||
--silent \
|
||||
--show-error \
|
||||
--fail-with-body \
|
||||
--header "Referer: ${WEBUI_HOST}" \
|
||||
--cookie-jar "${WEBUI_COOKIE_JAR}" \
|
||||
--data-urlencode "username=${WEBUI_USERNAME}" \
|
||||
--data-urlencode "password=${WEBUI_PASSWORD}" \
|
||||
"${WEBUI_HOST}/api/v2/auth/login"
|
||||
)
|
||||
if [[ "${login_response}" == "Ok." ]]; then
|
||||
WEBUI_COOKIE_ARGS=(--cookie "${WEBUI_COOKIE_JAR}")
|
||||
info "Authenticated with qBittorrent Web UI."
|
||||
else
|
||||
info "Warning: qBittorrent Web UI login failed: ${login_response}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# loop now forever keeping port forward up to date (protonvpn)
|
||||
# https://protonvpn.com/support/port-forwarding-manual-setup
|
||||
while true; do
|
||||
@@ -111,22 +144,54 @@ while true; do
|
||||
udp_output=$(natpmpc -a 1 0 udp 60 -g 10.2.0.1)
|
||||
udp_port=$(echo "${udp_output}" | sed -n 's/.*Mapped public port \([0-9]\+\).*/\1/p')
|
||||
|
||||
if ! [[ "${tcp_port}" =~ ^[0-9]+$ && "${udp_port}" =~ ^[0-9]+$ ]]; then
|
||||
info "Warning: unable to parse forwarded ports. tcp='${tcp_port}' udp='${udp_port}'"
|
||||
sleep 45 &
|
||||
wait ${!}
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "${tcp_port}" -ne "${udp_port}" ]]; then
|
||||
info "Warning: tcp_port (${tcp_port}) and udp_port (${udp_port}) are different"
|
||||
fi
|
||||
|
||||
# failure to connect to webui, we don't want to fail the loop, just log the error and try again
|
||||
current_port=$(curl --silent --header "Referer: ${WEBUI_HOST}" "${WEBUI_HOST}/api/v2/app/preferences" | jq .listen_port || true)
|
||||
preferences=$(qb_webui_curl "${WEBUI_HOST}/api/v2/app/preferences")
|
||||
if [[ "${?}" -ne 0 ]]; then
|
||||
info "Warning: unable to read qBittorrent preferences from ${WEBUI_HOST}"
|
||||
sleep 45 &
|
||||
wait ${!}
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "${tcp_port}" -ne "${current_port}" ]]; then
|
||||
info "Port changed from '${current_port}' to '${tcp_port}'. Updating app preferences..."
|
||||
current_port=$(echo "${preferences}" | jq -r .listen_port)
|
||||
random_port=$(echo "${preferences}" | jq -r .random_port)
|
||||
upnp=$(echo "${preferences}" | jq -r .upnp)
|
||||
if ! [[ "${current_port}" =~ ^[0-9]+$ ]]; then
|
||||
info "Warning: qBittorrent preferences did not contain a numeric listen_port: ${current_port}"
|
||||
sleep 45 &
|
||||
wait ${!}
|
||||
continue
|
||||
fi
|
||||
|
||||
curl \
|
||||
--silent \
|
||||
--header "Referer: ${WEBUI_HOST}" \
|
||||
if [[ "${tcp_port}" -ne "${current_port}" || "${random_port}" != "false" || "${upnp}" != "false" ]]; then
|
||||
info "Port settings changed from listen_port=${current_port}, random_port=${random_port}, upnp=${upnp} to listen_port=${tcp_port}, random_port=false, upnp=false. Updating app preferences..."
|
||||
|
||||
qb_webui_curl \
|
||||
--request POST \
|
||||
--data "json={\"listen_port\": ${tcp_port}}" \
|
||||
"${WEBUI_HOST}/api/v2/app/setPreferences" || true
|
||||
--data "json={\"listen_port\": ${tcp_port}, \"random_port\": false, \"upnp\": false}" \
|
||||
"${WEBUI_HOST}/api/v2/app/setPreferences"
|
||||
if [[ "${?}" -ne 0 ]]; then
|
||||
info "Warning: unable to update qBittorrent port preferences"
|
||||
sleep 45 &
|
||||
wait ${!}
|
||||
continue
|
||||
fi
|
||||
|
||||
updated_port=$(qb_webui_curl "${WEBUI_HOST}/api/v2/app/preferences" | jq -r .listen_port)
|
||||
if [[ "${updated_port}" != "${tcp_port}" ]]; then
|
||||
info "Warning: qBittorrent still reports listen_port=${updated_port} after update"
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 45 &
|
||||
|
||||
Reference in New Issue
Block a user