mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-18 06:01:52 +03:00
0e456f33c1
This is mainly to avoid downloaded files being owned by root which requires another one or two commands to change the file ownership.
35 lines
941 B
Bash
Executable file
35 lines
941 B
Bash
Executable file
#!/bin/sh
|
|
|
|
downloadsPath="/downloads"
|
|
profilePath="/config"
|
|
qbtConfigFile="$profilePath/qBittorrent/config/qBittorrent.conf"
|
|
|
|
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
|
|
|
|
if [ "$QBT_EULA" = "accept" ]; then
|
|
sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1true|}}' "$qbtConfigFile"
|
|
else
|
|
sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1false|}}' "$qbtConfigFile"
|
|
fi
|
|
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"
|
|
|
|
doas -u qbtUser \
|
|
qbittorrent-nox \
|
|
--profile="$profilePath" \
|
|
--webui-port="$QBT_WEBUI_PORT" \
|
|
"$@"
|