2021-09-20 23:56:27 +02:00
|
|
|
#!/usr/bin/with-contenv bash
|
|
|
|
|
|
|
|
echo '------------------------------'
|
|
|
|
echo '| qBittorrent theme.park Mod |'
|
|
|
|
echo '------------------------------'
|
|
|
|
|
|
|
|
APP_FILEPATH='/config/qBittorrent/qBittorrent.conf'
|
|
|
|
if [ "${TP_HOTIO}" = true ]; then
|
|
|
|
echo 'Changing to Hotio file path!'
|
|
|
|
APP_FILEPATH='/config/config/qBittorrent.conf'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Backup config
|
|
|
|
if [[ ! -f "${APP_FILEPATH}.bak" ]]; then
|
|
|
|
echo "Creating qBittorrent.conf backup in /config."
|
|
|
|
cp -p ${APP_FILEPATH} "${APP_FILEPATH}.bak"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Restore qBittorrent.conf
|
|
|
|
if [ "${TP_DISABLE_THEME}" = true ]; then
|
|
|
|
echo "Restoring backup of qBittorrent.conf"
|
|
|
|
sed -i "s/WebUI\\\AlternativeUIEnabled=.*$/WebUI\\\AlternativeUIEnabled=false/g" "${APP_FILEPATH}";
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [[ -x "$(command -v svn)" ]]; then
|
|
|
|
echo '--------------------------'
|
|
|
|
echo '| Installing svn package |'
|
|
|
|
echo '--------------------------'
|
2022-01-04 01:09:26 +01:00
|
|
|
if [ -x "$(command -v apk)" ]; then
|
|
|
|
apk update && \
|
|
|
|
apk add --no-cache subversion
|
|
|
|
elif [ -x "$(command -v apt-get)" ]; then
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -y subversion
|
|
|
|
fi
|
2021-09-20 23:56:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Display variables for troubleshooting
|
|
|
|
echo -e "Variables set:\\n\
|
|
|
|
'APP_FILEPATH'=${APP_FILEPATH}\\n\
|
|
|
|
'TP_DISABLE_THEME'=${TP_DISABLE_THEME}\\n\
|
|
|
|
'TP_HOTIO'=${TP_HOTIO}\\n\
|
|
|
|
'TP_DOMAIN'=${TP_DOMAIN}\\n\
|
2021-10-31 15:56:37 +01:00
|
|
|
'TP_COMMUNITY_THEME'=${TP_COMMUNITY_THEME}\\n\
|
2022-03-23 21:28:28 +01:00
|
|
|
'TP_SCHEME'=${TP_SCHEME}\\n\
|
2021-09-20 23:56:27 +02:00
|
|
|
'TP_THEME'=${TP_THEME}\\n"
|
|
|
|
|
|
|
|
# Set default
|
|
|
|
if [[ -z ${TP_DOMAIN} ]]; then
|
|
|
|
echo 'No domain set, defaulting to theme-park.dev'
|
|
|
|
TP_DOMAIN='theme-park.dev'
|
|
|
|
fi
|
2022-03-23 21:28:28 +01:00
|
|
|
if [[ -z ${TP_SCHEME} ]]; then
|
|
|
|
echo 'No scheme set, defaulting to https'
|
|
|
|
TP_SCHEME='https'
|
|
|
|
fi
|
2021-09-20 23:56:27 +02:00
|
|
|
|
2021-10-31 15:56:37 +01:00
|
|
|
THEME_TYPE='theme-options'
|
|
|
|
if [ "${TP_COMMUNITY_THEME}" = true ]; then
|
|
|
|
THEME_TYPE='community-theme-options'
|
|
|
|
fi
|
|
|
|
|
2021-09-20 23:56:27 +02:00
|
|
|
case ${TP_DOMAIN} in
|
|
|
|
*"github.io"*)
|
|
|
|
echo "Switching to github.io URL style"
|
|
|
|
TP_DOMAIN="${TP_DOMAIN}\/theme.park"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [[ -z ${TP_THEME} ]]; then
|
2021-10-31 15:56:37 +01:00
|
|
|
echo 'No theme set, defaulting to organizr'
|
2021-10-17 16:59:34 +02:00
|
|
|
TP_THEME='organizr'
|
2021-09-20 23:56:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Downloading fresh webui files from source.
|
|
|
|
if [[ ! -d /themepark ]]; then
|
|
|
|
echo '---------------------------------------'
|
|
|
|
echo '| Downloading WebUI files from github |'
|
|
|
|
echo '---------------------------------------'
|
|
|
|
printf '\nDownloading qBittorrent webui to "/themepark"..please wait\n'
|
|
|
|
svn export --quiet https://github.com/qbittorrent/qBittorrent/trunk/src/webui/www /themepark
|
|
|
|
printf '\nDownload finished\n\n'
|
|
|
|
printf '\nDownloading qBittorrent webui icons to "/themepark/xxx"..please wait\n'
|
|
|
|
svn export --force --quiet https://github.com/qbittorrent/qBittorrent/trunk/src/icons /temp
|
|
|
|
cp -a /temp/. /themepark/public/icons
|
|
|
|
cp -a /temp/. /themepark/private/icons
|
|
|
|
rm -rf /temp
|
|
|
|
printf '\nDownload finished\n\n'
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed_file(){
|
2022-03-23 21:28:28 +01:00
|
|
|
sed -i "s/<\/body>/<link rel='stylesheet' href='${TP_SCHEME}:\/\/${TP_DOMAIN}\/css\/base\/qbittorrent\/qbittorrent-base.css'><\/body> /g" $1
|
|
|
|
sed -i "s/<\/body>/<link rel='stylesheet' href='${TP_SCHEME}:\/\/${TP_DOMAIN}\/css\/${THEME_TYPE}\/${TP_THEME}.css'><\/body> /g" $1
|
2021-09-20 23:56:27 +02:00
|
|
|
printf 'Stylesheet set to %s on %s\n\n' "${TP_THEME}" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Adding stylesheets
|
|
|
|
echo '---------------------------------------'
|
|
|
|
echo '| Adding the stylesheet to html files |'
|
|
|
|
echo '---------------------------------------'
|
2021-11-02 00:14:23 +01:00
|
|
|
if ! grep -q "${TP_DOMAIN}/css/base" /themepark/public/index.html; then
|
2021-09-20 23:56:27 +02:00
|
|
|
sed_file /themepark/public/index.html
|
|
|
|
fi
|
|
|
|
|
2021-11-02 00:14:23 +01:00
|
|
|
if ! grep -q "${TP_DOMAIN}/css/base" /themepark/private/index.html; then
|
2021-09-20 23:56:27 +02:00
|
|
|
find ./themepark/private -type f -iname *.html | while read fname
|
|
|
|
do
|
|
|
|
sed_file $fname
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q "WebUI\\\RootFolder" "${APP_FILEPATH}"; then
|
|
|
|
echo '--------------------------------------'
|
|
|
|
echo '| Adding WebUI\RootFolder=/themepark |'
|
|
|
|
echo '--------------------------------------'
|
|
|
|
sed -i -e '$aWebUI\\RootFolder=/themepark' "${APP_FILEPATH}";
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q "WebUI\\\AlternativeUIEnabled" "${APP_FILEPATH}"; then
|
|
|
|
echo '------------------------------------------'
|
|
|
|
echo '| Adding WebUI\AlternativeUIEnabled=true |'
|
|
|
|
echo '------------------------------------------'
|
|
|
|
sed -i -e '$aWebUI\\AlternativeUIEnabled=true' "${APP_FILEPATH}";
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q "WebUI\\\RootFolder=/themepark" "${APP_FILEPATH}" || ! grep -q "WebUI\\\AlternativeUIEnabled=true" "${APP_FILEPATH}"; then
|
|
|
|
echo '-------------------------------------------------------'
|
|
|
|
echo '| Updating RootFolder and AlternativeUIEnabled values |'
|
|
|
|
echo '-------------------------------------------------------'
|
|
|
|
sed -i "s/WebUI\\\AlternativeUIEnabled=.*$/WebUI\\\AlternativeUIEnabled=true/g" "${APP_FILEPATH}";
|
|
|
|
sed -i "s/WebUI\\\RootFolder=.*$/WebUI\\\RootFolder=\/themepark/g" "${APP_FILEPATH}";
|
|
|
|
fi
|