-
-
Notifications
You must be signed in to change notification settings - Fork 838
Expand file tree
/
Copy path98-themepark
More file actions
executable file
·91 lines (78 loc) · 2.91 KB
/
Copy path98-themepark
File metadata and controls
executable file
·91 lines (78 loc) · 2.91 KB
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
#!/command/with-contenv bash
echo '---------------------------'
echo '| Sonarr theme.park Mod |'
echo '---------------------------'
# Display variables for troubleshooting
echo -e "Variables set:\\n\
'TP_DOMAIN'=${TP_DOMAIN}\\n\
'TP_COMMUNITY_THEME'=${TP_COMMUNITY_THEME}\\n\
'TP_SCHEME'=${TP_SCHEME}\\n\
'TP_ADDON'=${TP_ADDON}\\n\
'TP_THEME'=${TP_THEME}\\n"
APP_FILEPATH='/app/sonarr/bin/UI/index.html'
LOGIN_FILEPATH='/app/sonarr/bin/UI/login.html'
APP_ICON_FILEPATH='/app/sonarr/bin/UI/Content/Images/Icons'
if [ "${TP_HOTIO}" = true ]; then
echo 'Changing to Hotio file path!'
APP_FILEPATH='/app/bin/UI/index.html'
LOGIN_FILEPATH='/app/bin/UI/login.html'
APP_ICON_FILEPATH='/app/bin/UI/Content/Images/Icons'
fi
# 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
# Function to download files for a given addon
download_favicon_files() {
local addon=$1
local urls=$(curl -s "${TP_SCHEME}://${TP_DOMAIN}/themes.json" | jq -r ".addons.sonarr[\"$addon\"].files[]?")
for url in $urls; do
# Remove the query parameters from the URL
clean_url="${url%%\?*}"
wget -O "${APP_ICON_FILEPATH}/$(basename "${clean_url}")" "${clean_url}"
printf 'Downloaded favicon: %s\n' "${clean_url}"
done
}
# Adding stylesheets
if ! grep -q "${TP_DOMAIN}/css/base" "${APP_FILEPATH}"; then
echo '---------------------------'
echo '| Adding the stylesheets |'
echo '---------------------------'
url_base="${TP_SCHEME}://${TP_DOMAIN}"
sheets="<link rel='stylesheet' href='${url_base}/css/base/sonarr/sonarr-base.css'>"
sheets="${sheets} <link rel='stylesheet' href='${url_base}/css/${THEME_TYPE}/${TP_THEME}.css'>"
printf 'Stylesheet set to %s\n' "${TP_THEME}"
if [[ -n ${TP_ADDON} ]]; then
for addon in $(echo "$TP_ADDON" | tr "|" " "); do
sheets="${sheets} <link rel='stylesheet' href='${url_base}/css/addons/sonarr/${addon}/${addon}.css'>"
# If the addon variable has "favicon" in it, download all the favicon files from the themes.json file.
if [[ ${addon} == *"favicon"* ]]; then
echo 'Downloading favicon files...'
download_favicon_files "$addon"
fi
printf 'Added custom addon: %s\n\n' "${addon}"
done
fi
sed -i "s!</body>!${sheets}</body>!g" "${APP_FILEPATH}"
sed -i "s!</body>!${sheets}</body>!g" "${LOGIN_FILEPATH}"
printf 'Stylesheets inserted.'
fi