Add backward compatibility for environment variable

The new `QBT_LEGAL_NOTICE` variable will obsolete `QBT_EULA`. Its appearance (and therefore
documentation) is scheduled at the next major qbt release.
This commit is contained in:
Chocobo1 2023-11-26 15:54:40 +08:00
parent f0f3c8d71b
commit e538c1bd8f
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
2 changed files with 20 additions and 6 deletions

View File

@ -37,11 +37,18 @@ Accepted=false
EOF
fi
_eula=$(echo "$QBT_EULA" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
if [ "$_eula" = "accept" ]; then
_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
sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1false|}}' "$qbtConfigFile"
# 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

View File

@ -37,11 +37,18 @@ Accepted=false
EOF
fi
_eula=$(echo "$QBT_EULA" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
if [ "$_eula" = "accept" ]; then
_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
sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1false|}}' "$qbtConfigFile"
# 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