diff --git a/qbittorrent/root/etc/cont-init.d/98-themepark b/qbittorrent/root/etc/cont-init.d/98-themepark
index 8eaf8dd1..4c89ce61 100644
--- a/qbittorrent/root/etc/cont-init.d/98-themepark
+++ b/qbittorrent/root/etc/cont-init.d/98-themepark
@@ -9,6 +9,20 @@ 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 |'
@@ -19,6 +33,9 @@ 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\
'TP_THEME'=${TP_THEME}\\n"
@@ -56,25 +73,24 @@ if [[ ! -d /themepark ]]; then
printf '\nDownload finished\n\n'
fi
+sed_file(){
+ sed -i "s/<\/head>/<\/head> /g" $1
+ printf 'Stylesheet set to %s on %s\n\n' "${TP_THEME}" "$1"
+}
+
# Adding stylesheets
+echo '---------------------------------------'
+echo '| Adding the stylesheet to html files |'
+echo '---------------------------------------'
if ! grep -q "${TP_DOMAIN}" /themepark/public/index.html; then
- echo '---------------------------------------------------------'
- echo '| Adding the stylesheet to /themepark/public/index.html |'
- echo '---------------------------------------------------------'
- sed -i "s/<\/head>/<\/head> /g" /themepark/public/index.html
- printf 'Stylesheet set to %s on public index.html\n' "${TP_THEME}"
+ sed_file /themepark/public/index.html
fi
if ! grep -q "${TP_DOMAIN}" /themepark/private/index.html; then
- echo '----------------------------------------------------------'
- echo '| Adding the stylesheet to /themepark/private/index.html |'
- echo '----------------------------------------------------------'
- sed -i "s/<\/head>/<\/head> /g" /themepark/private/index.html
- printf 'Stylesheet set to %s on private index.html\n\n' "${TP_THEME}"
- sed -i "s/<\/head>/<\/head> /g" /themepark/private/upload.html
- printf 'Stylesheet set to %s on private upload.html\n\n' "${TP_THEME}"
- sed -i "s/<\/head>/<\/head> /g" /themepark/private/download.html
- printf 'Stylesheet set to %s on private download.html\n\n' "${TP_THEME}"
+ find ./themepark/private -type f -iname *.html | while read fname
+ do
+ sed_file $fname
+ done
fi
if ! grep -q "WebUI\\\RootFolder" "${APP_FILEPATH}"; then