-
-
Notifications
You must be signed in to change notification settings - Fork 820
/
Copy pathrun
executable file
·133 lines (115 loc) · 4.63 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/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
# 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_COMMUNITY_THEME'=${TP_COMMUNITY_THEME}\\n\
'TP_SCHEME'=${TP_SCHEME}\\n\
'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
if [[ -z ${TP_SCHEME} ]]; then
echo 'No scheme set, defaulting to https'
TP_SCHEME='https'
fi
THEME_TYPE='theme-options'
if [ "${TP_COMMUNITY_THEME}" = true ]; then
THEME_TYPE='community-theme-options'
fi
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
echo 'No theme set, defaulting to organizr'
TP_THEME='organizr'
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(){
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
printf 'Stylesheet set to %s on %s\n\n' "${TP_THEME}" "$1"
}
clean_file() {
perl -i -pe 's/QBT_TR?\(//g' "$1"
perl -i -pe 's/\)QBT_TR\[CONTEXT=.*?\]//g' "$1"
}
if ! grep -q "${TP_DOMAIN}/css/base" /themepark/public/index.html; then
# Adding stylesheets
echo '---------------------------------------'
echo '| Adding the stylesheet to html files |'
echo '---------------------------------------'
sed_file /themepark/public/index.html
clean_file /themepark/public/index.html
find /themepark/private -type f -iname "*.html" | while read fname
do
sed_file $fname
done
fi
# Clean all files
echo '------------------------------------------------------------'
echo '| Cleaning files in /themepark for any translation text... |'
echo '------------------------------------------------------------'
find /themepark -type f \( ! -iname "*.svg" \) | while read fname
do
clean_file $fname
done
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