t-anc / GSP-Qbittorent-Gluetun-sync-port-mod

Docker mod for Linuxserver's Qbittorrent image to sync gluetun's forwarded port. Can also work with any qBittorrent image as a standalone container.
GNU General Public License v3.0
70 stars 3 forks source link

./run: line 169: [: null: integer expression expected #12

Closed olvier closed 4 days ago

olvier commented 1 week ago

hi :)

first of all, thank you for your efforts with those 3 ports for perfect privacy! This is what i need, because i have multiple qbit instances <3

edit: first i had some other errors, but i fixed it for myself. Now, just another problem ;)

Any idea?

[custom-init] No custom files found, skipping...
+---------------------------------------------------------+
|           Gluetun sync port (GSP) mod loaded            |
+---------------------------------------------------------+
|  Qbittorrent address : http://localhost:32769           |
|  Gluetun address     : http://localhost:8000            |
|  GTN port index      : 3                                |
+---------------------------------------------------------+
10/06/24 23:23:51 [GSP] - Waiting for Qbittorrent WebUI ...
WebUI will be started shortly after internal preparations. Please wait...
******** Information ********
To control qBittorrent, access the WebUI at: http://localhost:32769
Connection to localhost (127.0.0.1) 32769 port [tcp/*] succeeded!
[ls.io-init] done.
10/06/24 23:24:09 [GSP] - Init checks passed. Listening for a change.
./run: line 169: [: null: integer expression expected
Ok.10/06/24 23:24:09 [GSP] - Ports changed :
10/06/24 23:24:09 [GSP] -  - Old : 0
10/06/24 23:24:09 [GSP] -  - New : null
10/06/24 23:24:09 [GSP] - Updating qbittorrent port via API ...
10/06/24 23:24:09 [GSP] - ERROR updating qbittorrent port !
2024-10-06T23:24:01+02:00 INFO [firewall] setting allowed input port 10505 through interface tun0...
2024-10-06T23:24:01+02:00 INFO [firewall] setting allowed input port 20505 through interface tun0...
2024-10-06T23:24:01+02:00 INFO [firewall] setting allowed input port 30505 through interface tun0...

this, when i use my own old script manually.

./run: line 169: [: null: integer expression expected
Ok.10/06/24 23:32:10 [GSP] - Ports changed :
10/06/24 23:32:10 [GSP] -  - Old : 30505
10/06/24 23:32:10 [GSP] -  - New : null
10/06/24 23:32:10 [GSP] - Updating qbittorrent port via API ...
10/06/24 23:32:10 [GSP] - ERROR updating qbittorrent port !
./run: line 169: [: null: integer expression expected
Ok.10/06/24 23:32:20 [GSP] - Ports changed :
10/06/24 23:32:20 [GSP] -  - Old : 0
10/06/24 23:32:20 [GSP] -  - New : null
10/06/24 23:32:20 [GSP] - Updating qbittorrent port via API ...
10/06/24 23:32:20 [GSP] - ERROR updating qbittorrent port !
t-anc commented 5 days ago

Hi, Yes, this looks like a bug. Can you share your compose file please ? (remove any credential) And could you run it with GSP_DEBUG=true and share the logs ? Thanks

olvier commented 5 days ago

of course i can :)

hi!

compose file

services:
    gluetun:
        image: qmcgaw/gluetun:v3.39.0   # :latest wont work, with new update (auth stuff with control server?)
        container_name: vpn_qmcgaw-gluetun
        restart: always     # restart: unless-stopped maybe ???
        cap_add:
            - NET_ADMIN
        environment:
            - TZ=Europe/Berlin
            - VPN_SERVICE_PROVIDER=perfect privacy
            - OPENVPN_USER=pp1234567
            - OPENVPN_PASSWORD=m4g1cp455word
            - SERVER_CITIES=Rotterdam
          # - VPN_TYPE=wireguard OR openvpn
            - VPN_PORT_FORWARDING=on
          # - VPN_PORT_FORWARDING_PROVIDER=protonvpn
        ports:
            - 8888:8888/tcp # HTTP proxy
            - 8388:8388/tcp # Shadowsocks
            - 8388:8388/udp # Shadowsocks
            - 8002:8000     # API, ControlServer etc.
            - 32768:32768   # ????
            - 32769:32769   # qBittorrent · movies · DS918+
            - 32779:32779   # qBittorrent · series · DS918+
        volumes:
            - /volume1/docker/gluetun/config.toml:/gluetun/auth/config.toml:ro
        # restart: no     # from 'docker run'
        # --label='telegram-notifier.monitor=false'     # from 'docker run'

    qbittorrent:
      # image: ghcr.io/linuxserver/qbittorrent          # orig
        image: linuxserver/qbittorrent
        container_name: qbittorrent_vpn_movies
        environment:
            - TZ=Europe/Berlin
            - WEBUI_PORT=32769
            - PUID=1026
            - PGID=100
            - DOCKER_MODS=ghcr.io/t-anc/gsp-qbittorent-gluetun-sync-port-mod:main
            - GSP_GTN_ADDR=http://localhost:8000
            # done with 'openssl rand -base64 50'
            - GSP_GTN_API_KEY=maaaaaaaaagic
            - GSP_GTN_PORT_INDEX=3     # Port for qBittorrent · movies · DS918+
          # - GSP_GTN_PORT_INDEX=2     # Port for qBittorrent · series · DS918+
            - GSP_QBT_USERNAME=olvier
            - GSP_QBT_PASSWORD=anotherm4g1cp455word
            - GSP_MINIMAL_LOGS=false
            - GSP_DEBUG=true
        volumes:
          # - "./qbittorrent/config/:/config"     # orig
            - /volume1/docker/qbittorrent/movies_config:/config
          # - "./qbittorrent/webui/:/webui"       # orig
          # - "./download:/download"              # orig
          # - 'burpe9695burp:/downloads'   # ??? from 'docker run'
            - /volume1/Daten/rutorrent/completed:/downloads/hdd1
            - /volume2/Video2/handselected:/downloads/hdd2
            - /volume2/Video2/handselected_hardlink:/downloads/hdd2_hardlink
            - /volume2/Video2/mergerfs:/downloads/mergerfs    # ???
            - /volume3/Video3:/downloads/hdd3
            - /volume4/Video4:/downloads/hdd4
            - /volume5/Video5:/downloads/hdd5
        network_mode: container:vpn_qmcgaw-gluetun
      # network_mode: service:gluetun ???
        depends_on:
            gluetun:
                condition: service_healthy
        restart: unless-stopped

logs of gluetun

2024-10-07T21:49:33+02:00 INFO [openvpn] OpenVPN 2.6.11 x86_64-alpine-linux-musl [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD]
2024-10-07T21:49:33+02:00 INFO [openvpn] library versions: OpenSSL 3.3.1 4 Jun 2024, LZO 2.10
2024-10-07T21:49:33+02:00 WARN [openvpn] No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
2024-10-07T21:49:33+02:00 INFO [openvpn] TCP/UDP: Preserving recently used remote address: [AF_INET]31.204.MMM.NNN:443
2024-10-07T21:49:33+02:00 INFO [openvpn] UDPv4 link local: (not bound)
2024-10-07T21:49:33+02:00 INFO [openvpn] UDPv4 link remote: [AF_INET]31.204.MMM.NNN:443
2024-10-07T21:49:33+02:00 INFO [openvpn] [Server_rotterdam.perfect-privacy.com] Peer Connection Initiated with [AF_INET]31.204.150.106:443
2024-10-07T21:49:34+02:00 INFO [openvpn] TUN/TAP device tun0 opened
2024-10-07T21:49:34+02:00 INFO [openvpn] /sbin/ip link set dev tun0 up mtu 1500
2024-10-07T21:49:34+02:00 INFO [openvpn] /sbin/ip link set dev tun0 up
2024-10-07T21:49:34+02:00 INFO [openvpn] /sbin/ip addr add dev tun0 10.1.XXX.YYY/24
2024-10-07T21:49:34+02:00 INFO [openvpn] UID set to nonrootuser
2024-10-07T21:49:34+02:00 INFO [openvpn] Initialization Sequence Completed
2024-10-07T21:49:34+02:00 INFO [dns] downloading DNS over TLS cryptographic files
2024-10-07T21:49:35+02:00 INFO [healthcheck] healthy!
2024-10-07T21:49:36+02:00 INFO [dns] downloading hostnames and IP block lists
2024-10-07T21:49:48+02:00 INFO [dns] init module 0: validator
2024-10-07T21:49:48+02:00 INFO [dns] init module 1: iterator
2024-10-07T21:49:48+02:00 INFO [dns] start of service (unbound 1.20.0).
2024-10-07T21:49:49+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66-9728. NULL IN
2024-10-07T21:49:49+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66-9728. NULL IN
2024-10-07T21:49:49+02:00 INFO [dns] ready
2024-10-07T21:49:49+02:00 INFO [healthcheck] healthy!
2024-10-07T21:49:49+02:00 INFO [ip getter] Public IP address is 31.204.MMM.PPP (Netherlands, South Holland, Rotterdam)
2024-10-07T21:49:50+02:00 INFO [vpn] There is a new release v3.39.1 (v3.39.1) created 8 days ago
2024-10-07T21:49:50+02:00 INFO [port forwarding] starting
2024-10-07T21:49:50+02:00 INFO [port forwarding] ports forwarded are 10033, 20033 and 30033
2024-10-07T21:49:50+02:00 INFO [firewall] setting allowed input port 10033 through interface tun0...
2024-10-07T21:49:50+02:00 INFO [firewall] setting allowed input port 20033 through interface tun0...
2024-10-07T21:49:50+02:00 INFO [firewall] setting allowed input port 30033 through interface tun0...
2024-10-07T21:49:50+02:00 INFO [port forwarding] writing port file /tmp/gluetun/forwarded_port
2024-10-07T21:50:01+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:39864 in 189.634µs
2024-10-07T21:50:01+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:39870 in 56.852µs
2024-10-07T21:50:11+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:39916 in 54.536µs
2024-10-07T21:50:21+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:39962 in 67.099µs
2024-10-07T21:50:31+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:40004 in 54.899µs
2024-10-07T21:50:41+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:40038 in 55.617µs
2024-10-07T21:50:52+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:40108 in 56.445µs
2024-10-07T21:51:11+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:40242 in 118.332µs
2024-10-07T21:51:12+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:40248 in 53.863µs
2024-10-07T21:51:22+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:40292 in 56.091µs
2024-10-07T21:51:32+02:00 INFO [http server] 200 GET /portforwarded wrote 30B to 127.0.0.1:40330 in 55.81µs

logs qbit

───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1026
User GID:    100
───────────────────────────────────────
Linuxserver.io version: 4.6.5-r0-ls343
Build-date: 2024-07-28T06:52:43+00:00
───────────────────────────────────────

[custom-init] No custom files found, skipping...
+---------------------------------------------------------+
|           Gluetun sync port (GSP) mod loaded            |
+---------------------------------------------------------+
|  Qbittorrent address : http://localhost:32769           |
|  Gluetun address     : http://localhost:8000            |
|  GTN port index      : 3                                |
+---------------------------------------------------------+
10/07/24 21:50:59 [GSP] - Debug mode enabled.
+ log 'Waiting for Qbittorrent WebUI ...'
++ date '+%x %T'
+ echo '10/07/24 21:50:59 [GSP] - Waiting for Qbittorrent WebUI ...'
+ curl --retry 10 --retry-all-errors --retry-delay 6 -s -o /dev/null http://localhost:32769
10/07/24 21:50:59 [GSP] - Waiting for Qbittorrent WebUI ...
WebUI will be started shortly after internal preparations. Please wait...
******** Information ********
To control qBittorrent, access the WebUI at: http://localhost:32769
Connection to localhost (127.0.0.1) 32769 port [tcp/*] succeeded!
[ls.io-init] done.
+ init_checks
+ '[' '' = true ']'
+ '[' '' = warning ']'
+ MSG_prefix='[ERROR]'
+ conf_file=/config/qBittorrent/qBittorrent.conf
+ '[' '!' -f /config/qBittorrent/qBittorrent.conf ']'
+ '[' -z olvier ']'
+ '[' -z notforyoureyes ']'
+ '[' -n olvier ']'
+ '[' -n notforyoureyes ']'

++ qbt_login
++ curl --fail --silent --cookie-jar /tmp/cookies.txt --cookie /tmp/cookies.txt --url http://localhost:32769/api/v2/auth/login --data username=olvier --data password=notforyoureyes
+ '[' Ok. '!=' Ok. ']'
++ curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:32769
+ '[' 200 -eq 401 ']'
+ '[' -z API-THINGY ']'
++ curl --write-out '%{http_code}' --silent --output /dev/null -H X-API-Key:API-THINGY http://localhost:8000/v1/openvpn/portforwarded
+ '[' 200 -eq 401 ']'
+ '[' '[ERROR]' = '[ERROR]' ']'
+ '[' -n '' ']'
+ log 'Init checks passed. Listening for a change.'
++ date '+%x %T'
10/07/24 21:51:11 [GSP] - Init checks passed. Listening for a change.
+ echo '10/07/24 21:51:11 [GSP] - Init checks passed. Listening for a change.'
+ :
+ SLEEP_TIME=60
+ '[' -n olvier ']'
+ '[' -n notforyoureyes ']'
+ qbt_login
+ curl --fail --silent --cookie-jar /tmp/cookies.txt --cookie /tmp/cookies.txt --url http://localhost:32769/api/v2/auth/login --data username=olvier --data password=notforyoureyes
+ get_ports
+ case ${1,,} in
+ QBT=true
+ GTN=true
+ '[' true ']'
++ curl --silent --fail --show-error --cookie-jar /tmp/cookies.txt --cookie /tmp/cookies.txt http://localhost:32769/api/v2/app/preferences
++ jq .listen_port

+ QBT_PORT=0
+ '[' true ']'
++ curl --silent --fail --show-error -H X-API-Key:API-THINGY http://localhost:8000/v1/openvpn/portforwarded
++ jq .port
+ GTN_PORTS=null
+ echo null
+ grep -Fq '['
+ GTN_PORT=null
+ '[' -z null ']'
+ '[' null -eq 0 ']'
./run: line 169: [: null: integer expression expected
+ '[' -z 0 ']'
+ '[' 60 -ne 10 ']'
+ '[' 0 = null ']'
+ log 'Ports changed :'
++ date '+%x %T'
Ok.10/07/24 21:51:12 [GSP] - Ports changed :
+ echo '10/07/24 21:51:12 [GSP] - Ports changed :'
+ log ' - Old : 0'
++ date '+%x %T'
10/07/24 21:51:12 [GSP] -  - Old : 0
+ echo '10/07/24 21:51:12 [GSP] -  - Old : 0'
+ log ' - New : null'
++ date '+%x %T'
+ echo '10/07/24 21:51:12 [GSP] -  - New : null'
10/07/24 21:51:12 [GSP] -  - New : null
+ log 'Updating qbittorrent port via API ...'
++ date '+%x %T'
10/07/24 21:51:12 [GSP] - Updating qbittorrent port via API ...
+ echo '10/07/24 21:51:12 [GSP] - Updating qbittorrent port via API ...'
+ curl --silent --request POST --cookie-jar /tmp/cookies.txt --cookie /tmp/cookies.txt --url http://localhost:32769/api/v2/app/setPreferences --data 'json={"listen_port": null}'
+ get_ports qbt
+ case ${1,,} in
+ QBT=true
+ GTN=
root@a0c5286afc07:/# curl --silent --fail --show-error -H X-API-Key:API-THINGY http://localhost:8000/v1/openvpn/portforwa
rded
{"ports":[10033,20033,30033]}
t-anc commented 4 days ago

Oh ! I see what's the issue ! In the case of only one forwarded port, the output is something like {"port":34981}, however in the case of multiple ports, port is actually ports. During my dev I simulated gluetun (as I have only 1 port forwarded) and didn't see the difference. I'll fix this as soon as possible, probably tonight. Thank you for the logs etc :)

t-anc commented 4 days ago

Oops, didn't expected github to close it automaticly, sorry. Should be fixed, can you try and tell me please.

olvier commented 4 days ago

Hi,

can confirm, that this fixes "the error" :) thank you so much!

[mod-init] Running Docker Modification Logic
[mod-init] Adding t-anc/gsp-qbittorent-gluetun-sync-port-mod:main to container
[mod-init] Downloading t-anc/gsp-qbittorent-gluetun-sync-port-mod:main from ghcr.io
[mod-init] Installing t-anc/gsp-qbittorent-gluetun-sync-port-mod:main
[mod-init] t-anc/gsp-qbittorent-gluetun-sync-port-mod:main applied to container
[migrations] started
[migrations] no migrations found
───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1026
User GID:    100
───────────────────────────────────────
Linuxserver.io version: 4.6.7-r0-ls353
Build-date: 2024-09-29T06:57:28+00:00
───────────────────────────────────────

[custom-init] No custom files found, skipping...
+---------------------------------------------------------+
|           Gluetun sync port (GSP) mod loaded            |
+---------------------------------------------------------+
|  Qbittorrent address : http://localhost:32769           |
|  Gluetun address     : http://localhost:8000            |
|  GTN port index      : 3                                |
+---------------------------------------------------------+
10/08/24 22:11:26 [GSP] - Waiting for Qbittorrent WebUI ...
WebUI will be started shortly after internal preparations. Please wait...
******** Information ********
To control qBittorrent, access the WebUI at: http://localhost:32769
Connection to localhost (127.0.0.1) 32769 port [tcp/*] succeeded!
[ls.io-init] done.
10/08/24 22:11:39 [GSP] - Init checks passed. Listening for a change.
Ok.10/08/24 22:11:39 [GSP] - Ports did not change.
Ok.10/08/24 22:12:39 [GSP] - Ports did not change.
Ok.10/08/24 22:13:39 [GSP] - Ports did not change.
Ok.10/08/24 22:14:39 [GSP] - Ports did not change.
Ok.10/08/24 22:15:39 [GSP] - Ports did not change.
t-anc commented 4 days ago

No problem ! Thank for the feedbacks. I'll let you close the issue if everything is ok :)