Skip to content

Commit 45b7917

Browse files
committed
Add Torrenting Port environment variable
Closes #75.
1 parent 787c8bf commit 45b7917

File tree

9 files changed

+61
-26
lines changed

9 files changed

+61
-26
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
QBT_LEGAL_NOTICE=
44
QBT_VERSION=latest
5+
QBT_TORRENTING_PORT=6881
56
QBT_WEBUI_PORT=8080
67

78
QBT_CONFIG_PATH=<your_path>/config

Readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ https://github.com/qbittorrent/qBittorrent/issues
5757
For example, `4.4.5-1` is a valid entry. You can find all tagged versions [here](https://hub.docker.com/r/qbittorrentofficial/qbittorrent-nox/tags). \
5858
You can put `latest` to use the latest stable release of qBittorrent. \
5959
If you are up to test the bleeding-edge version, you can put `alpha` to get the weekly build.
60+
* `QBT_TORRENTING_PORT` \
61+
This environment variable sets the port number which torrenting traffic will be binded to.
62+
Defaults to port `6881` if value is not set.
6063
* `QBT_WEBUI_PORT` \
6164
This environment variable sets the port number which qBittorrent WebUI will be binded to.
6265
Defaults to port `8080` if value is not set.
@@ -78,6 +81,7 @@ https://github.com/qbittorrent/qBittorrent/issues
7881
export \
7982
QBT_LEGAL_NOTICE=<put_confirm_here> \
8083
QBT_VERSION=latest \
84+
QBT_TORRENTING_PORT=6881 \
8185
QBT_WEBUI_PORT=8080 \
8286
QBT_CONFIG_PATH="<your_path>/config" \
8387
QBT_DOWNLOADS_PATH="<your_path>/downloads"
@@ -89,10 +93,11 @@ https://github.com/qbittorrent/qBittorrent/issues
8993
--stop-timeout 1800 \
9094
--tmpfs /tmp \
9195
-e QBT_LEGAL_NOTICE \
96+
-e QBT_TORRENTING_PORT \
9297
-e QBT_WEBUI_PORT \
98+
-p "$QBT_TORRENTING_PORT":"$QBT_TORRENTING_PORT"/tcp \
99+
-p "$QBT_TORRENTING_PORT":"$QBT_TORRENTING_PORT"/udp \
93100
-p "$QBT_WEBUI_PORT":"$QBT_WEBUI_PORT"/tcp \
94-
-p 6881:6881/tcp \
95-
-p 6881:6881/udp \
96101
-v "$QBT_CONFIG_PATH":/config \
97102
-v "$QBT_DOWNLOADS_PATH":/downloads \
98103
qbittorrentofficial/qbittorrent-nox:${QBT_VERSION}

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ services:
1010
#- PUID=1000
1111
- QBT_LEGAL_NOTICE=${QBT_LEGAL_NOTICE}
1212
- QBT_VERSION=${QBT_VERSION}
13+
- QBT_TORRENTING_PORT=${QBT_TORRENTING_PORT}
1314
- QBT_WEBUI_PORT=${QBT_WEBUI_PORT}
1415
#- TZ=UTC
1516
#- UMASK=022
1617
image: qbittorrentofficial/qbittorrent-nox:${QBT_VERSION}
1718
ports:
1819
# for bittorrent traffic
19-
- 6881:6881/tcp
20-
- 6881:6881/udp
20+
- ${QBT_TORRENTING_PORT}:${QBT_TORRENTING_PORT}/tcp
21+
- ${QBT_TORRENTING_PORT}:${QBT_TORRENTING_PORT}/udp
2122
# for WebUI
2223
- ${QBT_WEBUI_PORT}:${QBT_WEBUI_PORT}/tcp
2324
read_only: true

docker-stack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
#- PGID=1000
1111
#- PUID=1000
1212
- QBT_LEGAL_NOTICE=
13+
- QBT_TORRENTING_PORT=6881
1314
- QBT_WEBUI_PORT=8080
1415
#- TZ=UTC
1516
#- UMASK=022

entrypoint.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,33 @@ if [ ! -f "$qbtConfigFile" ]; then
3838
Session\DefaultSavePath=$downloadsPath
3939
Session\Port=6881
4040
Session\TempPath=$downloadsPath/temp
41+
[Preferences]
42+
WebUI\Port=8080
4143
EOF
4244
fi
4345

44-
confirmLegalNotice=""
46+
argLegalNotice=""
4547
_legalNotice=$(echo "$QBT_LEGAL_NOTICE" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
4648
if [ "$_legalNotice" = "confirm" ]; then
47-
confirmLegalNotice="--confirm-legal-notice"
49+
argLegalNotice="--confirm-legal-notice"
4850
else
4951
# for backward compatibility
5052
# TODO: remove in next major version release
5153
_eula=$(echo "$QBT_EULA" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
5254
if [ "$_eula" = "accept" ]; then
5355
echo "QBT_EULA=accept is deprecated and will be removed soon. The replacement is QBT_LEGAL_NOTICE=confirm"
54-
confirmLegalNotice="--confirm-legal-notice"
56+
argLegalNotice="--confirm-legal-notice"
5557
fi
5658
fi
5759

58-
if [ -z "$QBT_WEBUI_PORT" ]; then
59-
QBT_WEBUI_PORT=8080
60+
argTorrentingPort=""
61+
if [ -n "$QBT_TORRENTING_PORT" ]; then
62+
argTorrentingPort="--torrenting-port=$QBT_TORRENTING_PORT"
63+
fi
64+
65+
argWebUIPort=""
66+
if [ -n "$QBT_WEBUI_PORT" ]; then
67+
argWebUIPort="--webui-port=$QBT_WEBUI_PORT"
6068
fi
6169

6270
if [ "$isRoot" = "1" ]; then
@@ -79,15 +87,17 @@ if [ "$isRoot" = "1" ]; then
7987
exec \
8088
doas -u qbtUser \
8189
qbittorrent-nox \
82-
"$confirmLegalNotice" \
90+
"$argLegalNotice" \
8391
--profile="$profilePath" \
84-
--webui-port="$QBT_WEBUI_PORT" \
92+
"$argTorrentingPort" \
93+
"$argWebUIPort" \
8594
"$@"
8695
else
8796
exec \
8897
qbittorrent-nox \
89-
"$confirmLegalNotice" \
98+
"$argLegalNotice" \
9099
--profile="$profilePath" \
91-
--webui-port="$QBT_WEBUI_PORT" \
100+
"$argTorrentingPort" \
101+
"$argWebUIPort" \
92102
"$@"
93103
fi

manual_build/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
QBT_LEGAL_NOTICE=
44
QBT_VERSION=devel
5+
QBT_TORRENTING_PORT=6881
56
QBT_WEBUI_PORT=8080
67

78
QBT_CONFIG_PATH=<your_path>/config

manual_build/Readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ It is also recommended to install Docker Compose as it can significantly ease th
4242
This environment variable specifies the version of qBittorrent-nox to be built. \
4343
For example, `4.4.0` is a valid entry. You can find all tagged versions [here](https://github.com/qbittorrent/qBittorrent/tags). \
4444
You can put `devel` to build the latest development version.
45+
* `QBT_TORRENTING_PORT` \
46+
This environment variable sets the port number which torrenting traffic will be binded to.
47+
Defaults to port `6881` if value is not set.
4548
* `QBT_WEBUI_PORT` \
4649
This environment variable sets the port number which qBittorrent WebUI will be binded to.
4750
Defaults to port `8080` if value is not set.
@@ -63,6 +66,7 @@ There are some paths involved:
6366
export \
6467
QBT_LEGAL_NOTICE=<put_confirm_here> \
6568
QBT_VERSION=devel \
69+
QBT_TORRENTING_PORT=6881 \
6670
QBT_WEBUI_PORT=8080 \
6771
QBT_CONFIG_PATH="<your_path>/config" \
6872
QBT_DOWNLOADS_PATH="<your_path>/downloads"
@@ -74,11 +78,12 @@ There are some paths involved:
7478
--stop-timeout 1800 \
7579
--tmpfs /tmp \
7680
-e QBT_LEGAL_NOTICE \
81+
-e QBT_TORRENTING_PORT \
7782
-e QBT_WEBUI_PORT \
7883
-e TZ=UTC \
84+
-p "$QBT_TORRENTING_PORT":"$QBT_TORRENTING_PORT"/tcp \
85+
-p "$QBT_TORRENTING_PORT":"$QBT_TORRENTING_PORT"/udp \
7986
-p "$QBT_WEBUI_PORT":"$QBT_WEBUI_PORT"/tcp \
80-
-p 6881:6881/tcp \
81-
-p 6881:6881/udp \
8287
-v "$QBT_CONFIG_PATH":/config \
8388
-v "$QBT_DOWNLOADS_PATH":/downloads \
8489
qbittorrent-nox:"$QBT_VERSION"

manual_build/docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ services:
1111
#- PUID=1000
1212
- QBT_LEGAL_NOTICE=${QBT_LEGAL_NOTICE}
1313
- QBT_VERSION=${QBT_VERSION}
14+
- QBT_TORRENTING_PORT=${QBT_TORRENTING_PORT}
1415
- QBT_WEBUI_PORT=${QBT_WEBUI_PORT}
1516
#- TZ=UTC
1617
#- UMASK=022
1718
image: qbittorrent-nox:${QBT_VERSION}
1819
ports:
1920
# for bittorrent traffic
20-
- 6881:6881/tcp
21-
- 6881:6881/udp
21+
- ${QBT_TORRENTING_PORT}:${QBT_TORRENTING_PORT}/tcp
22+
- ${QBT_TORRENTING_PORT}:${QBT_TORRENTING_PORT}/udp
2223
# for WebUI
2324
- ${QBT_WEBUI_PORT}:${QBT_WEBUI_PORT}/tcp
2425
read_only: true

manual_build/entrypoint.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,33 @@ if [ ! -f "$qbtConfigFile" ]; then
3838
Session\DefaultSavePath=$downloadsPath
3939
Session\Port=6881
4040
Session\TempPath=$downloadsPath/temp
41+
[Preferences]
42+
WebUI\Port=8080
4143
EOF
4244
fi
4345

44-
confirmLegalNotice=""
46+
argLegalNotice=""
4547
_legalNotice=$(echo "$QBT_LEGAL_NOTICE" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
4648
if [ "$_legalNotice" = "confirm" ]; then
47-
confirmLegalNotice="--confirm-legal-notice"
49+
argLegalNotice="--confirm-legal-notice"
4850
else
4951
# for backward compatibility
5052
# TODO: remove in next major version release
5153
_eula=$(echo "$QBT_EULA" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
5254
if [ "$_eula" = "accept" ]; then
5355
echo "QBT_EULA=accept is deprecated and will be removed soon. The replacement is QBT_LEGAL_NOTICE=confirm"
54-
confirmLegalNotice="--confirm-legal-notice"
56+
argLegalNotice="--confirm-legal-notice"
5557
fi
5658
fi
5759

58-
if [ -z "$QBT_WEBUI_PORT" ]; then
59-
QBT_WEBUI_PORT=8080
60+
argTorrentingPort=""
61+
if [ -n "$QBT_TORRENTING_PORT" ]; then
62+
argTorrentingPort="--torrenting-port=$QBT_TORRENTING_PORT"
63+
fi
64+
65+
argWebUIPort=""
66+
if [ -n "$QBT_WEBUI_PORT" ]; then
67+
argWebUIPort="--webui-port=$QBT_WEBUI_PORT"
6068
fi
6169

6270
if [ "$isRoot" = "1" ]; then
@@ -79,15 +87,17 @@ if [ "$isRoot" = "1" ]; then
7987
exec \
8088
doas -u qbtUser \
8189
qbittorrent-nox \
82-
"$confirmLegalNotice" \
90+
"$argLegalNotice" \
8391
--profile="$profilePath" \
84-
--webui-port="$QBT_WEBUI_PORT" \
92+
"$argTorrentingPort" \
93+
"$argWebUIPort" \
8594
"$@"
8695
else
8796
exec \
8897
qbittorrent-nox \
89-
"$confirmLegalNotice" \
98+
"$argLegalNotice" \
9099
--profile="$profilePath" \
91-
--webui-port="$QBT_WEBUI_PORT" \
100+
"$argTorrentingPort" \
101+
"$argWebUIPort" \
92102
"$@"
93103
fi

0 commit comments

Comments
 (0)