mirror of
https://github.com/qbittorrent/docker-qbittorrent-nox.git
synced 2024-11-27 03:10:32 +00:00
e538c1bd8f
The new `QBT_LEGAL_NOTICE` variable will obsolete `QBT_EULA`. Its appearance (and therefore documentation) is scheduled at the next major qbt release.
74 lines
2.0 KiB
Bash
Executable File
74 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
downloadsPath="/downloads"
|
|
profilePath="/config"
|
|
qbtConfigFile="$profilePath/qBittorrent/config/qBittorrent.conf"
|
|
|
|
if [ -n "$PUID" ]; then
|
|
sed -i "s|^qbtUser:x:[0-9]*:|qbtUser:x:$PUID:|g" /etc/passwd
|
|
fi
|
|
|
|
if [ -n "$PGID" ]; then
|
|
sed -i "s|^\(qbtUser:x:[0-9]*\):[0-9]*:|\1:$PGID:|g" /etc/passwd
|
|
sed -i "s|^qbtUser:x:[0-9]*:|qbtUser:x:$PGID:|g" /etc/group
|
|
fi
|
|
|
|
if [ -n "$PAGID" ]; then
|
|
_origIFS="$IFS"
|
|
IFS=','
|
|
for AGID in $PAGID; do
|
|
AGID=$(echo "$AGID" | tr -d '[:space:]"')
|
|
addgroup -g "$AGID" "qbtGroup-$AGID"
|
|
addgroup qbtUser "qbtGroup-$AGID"
|
|
done
|
|
IFS="$_origIFS"
|
|
fi
|
|
|
|
if [ ! -f "$qbtConfigFile" ]; then
|
|
mkdir -p "$(dirname $qbtConfigFile)"
|
|
cat << EOF > "$qbtConfigFile"
|
|
[BitTorrent]
|
|
Session\DefaultSavePath=/downloads
|
|
Session\Port=6881
|
|
Session\TempPath=/downloads/temp
|
|
|
|
[LegalNotice]
|
|
Accepted=false
|
|
EOF
|
|
fi
|
|
|
|
_legalNotice=$(echo "$QBT_LEGAL_NOTICE" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
|
|
if [ "$_legalNotice" = "confirm" ]; then
|
|
sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1true|}}' "$qbtConfigFile"
|
|
else
|
|
# for backward compatibility
|
|
# TODO: remove in next major version release
|
|
_eula=$(echo "$QBT_EULA" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
|
|
if [ "$_eula" = "accept" ]; then
|
|
sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1true|}}' "$qbtConfigFile"
|
|
else
|
|
sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1false|}}' "$qbtConfigFile"
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$QBT_WEBUI_PORT" ]; then
|
|
QBT_WEBUI_PORT=8080
|
|
fi
|
|
|
|
# those are owned by root by default
|
|
# don't change existing files owner in `$downloadsPath`
|
|
chown qbtUser:qbtUser "$downloadsPath"
|
|
chown qbtUser:qbtUser -R "$profilePath"
|
|
|
|
# set umask just before starting qbt
|
|
if [ -n "$UMASK" ]; then
|
|
umask "$UMASK"
|
|
fi
|
|
|
|
exec \
|
|
doas -u qbtUser \
|
|
qbittorrent-nox \
|
|
--profile="$profilePath" \
|
|
--webui-port="$QBT_WEBUI_PORT" \
|
|
"$@"
|