24 changed files with 206 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||||
|
#!/usr/bin/with-contenv bash |
||||
|
|
||||
|
if ! [[ -x "$(command -v svn)" ]]; then |
||||
|
echo "subversion" >> /mod-repo-packages-to-install.list |
||||
|
fi |
@ -0,0 +1 @@ |
|||||
|
oneshot |
@ -0,0 +1 @@ |
|||||
|
/etc/s6-overlay/s6-rc.d/init-mod-themepark-add-package/run |
@ -0,0 +1,54 @@ |
|||||
|
#!/usr/bin/with-contenv bash |
||||
|
|
||||
|
echo '-------------------------' |
||||
|
echo '| SWAG theme.park Mod |' |
||||
|
echo '-------------------------' |
||||
|
|
||||
|
# Display variables for troubleshooting |
||||
|
echo -e "Variables set:\\n\ |
||||
|
'TP_BRANCH'=${TP_BRANCH}\\n" |
||||
|
|
||||
|
# Set default |
||||
|
if [[ -z ${TP_BRANCH} ]]; then |
||||
|
echo 'No branch set, defaulting to live' |
||||
|
TP_BRANCH='live' |
||||
|
fi |
||||
|
|
||||
|
if [[ ${TP_BRANCH} == "master" ]]; then |
||||
|
TP_BRANCH='live' |
||||
|
fi |
||||
|
|
||||
|
if [[ ${TP_BRANCH} == "develop" ]]; then |
||||
|
TP_BRANCH='live_develop' |
||||
|
fi |
||||
|
|
||||
|
if [[ ${TP_BRANCH} == "testing" ]]; then |
||||
|
TP_BRANCH='live_testing' |
||||
|
fi |
||||
|
|
||||
|
mkdir -p /config/www/themepark |
||||
|
|
||||
|
SHA_RELEASE=$(curl -sL "https://api.github.com/repos/gilbn/theme.park/commits/${TP_BRANCH}" | jq -r '.sha'); |
||||
|
if [[ ! -f "/config/www/themepark/sha.txt" ]]; then |
||||
|
SHA="" |
||||
|
else |
||||
|
SHA=$(cat /config/www/themepark/sha.txt) |
||||
|
fi |
||||
|
# Downloading fresh webui files from source. |
||||
|
if [[ $SHA != $SHA_RELEASE ]]; then |
||||
|
echo "-----------------------------------------------------" |
||||
|
echo "| Downloading latest files from ${TP_BRANCH} branch |" |
||||
|
echo "-----------------------------------------------------" |
||||
|
svn export --quiet --force "https://github.com/GilbN/theme.park/branches/${TP_BRANCH}/css" /config/www/themepark/css |
||||
|
svn export --quiet --force "https://github.com/GilbN/theme.park/branches/${TP_BRANCH}/resources" /config/www/themepark/resources |
||||
|
svn export --quiet --force "https://github.com/GilbN/theme.park/branches/${TP_BRANCH}/themes.json" /config/www/themepark |
||||
|
svn export --quiet --force "https://github.com/GilbN/theme.park/branches/${TP_BRANCH}/index.html" /config/www/themepark |
||||
|
printf '\nDownload finished\n\n' |
||||
|
fi |
||||
|
|
||||
|
cat <<< "$SHA_RELEASE" > "/config/www/themepark/sha.txt" |
||||
|
cp /themepark-confs/* /config/nginx/proxy-confs |
||||
|
|
||||
|
# permissions |
||||
|
chown -R abc:abc \ |
||||
|
/config/www/themepark |
@ -0,0 +1 @@ |
|||||
|
oneshot |
@ -0,0 +1 @@ |
|||||
|
/etc/s6-overlay/s6-rc.d/init-mod-themepark/run |
@ -0,0 +1,5 @@ |
|||||
|
#!/usr/bin/with-contenv bash |
||||
|
|
||||
|
if ! [[ -x "$(command -v jq)" ]]; then |
||||
|
echo "jq" >> /mod-repo-packages-to-install.list |
||||
|
fi |
@ -0,0 +1 @@ |
|||||
|
oneshot |
@ -0,0 +1 @@ |
|||||
|
/etc/s6-overlay/s6-rc.d/init-mod-themepark-add-package/run |
@ -0,0 +1,134 @@ |
|||||
|
#!/usr/bin/with-contenv bash |
||||
|
APP_FILEPATH='/config/qBittorrent/qBittorrent.conf' |
||||
|
INDEX_FILEPATH='/vuetorrent/public/index.html' |
||||
|
if [ "${TP_HOTIO}" = true ]; then |
||||
|
echo 'Changing to Hotio file paths!' |
||||
|
APP_FILEPATH='/config/config/qBittorrent.conf' |
||||
|
INDEX_FILEPATH='/app/vuetorrent/public/index.html' |
||||
|
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\ |
||||
|
'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 |
||||
|
RELEASE_FILEPATH='/vuetorrent/release.json' |
||||
|
NEEDS_UPDATE=false |
||||
|
CURRENT_RELEASE=$(curl -s https://api.github.com/repos/WDaan/VueTorrent/releases/latest | jq -r ".assets[]") |
||||
|
|
||||
|
# =============================================== |
||||
|
check_updates() { |
||||
|
if [[ ! -d ./vuetorrent ]]; then |
||||
|
NEEDS_UPDATE=true |
||||
|
elif [[ ! -f $RELEASE_FILEPATH ]]; then |
||||
|
NEEDS_UPDATE=true |
||||
|
else |
||||
|
old_date=$(date -d $(cat "${RELEASE_FILEPATH}" | jq -r ".updated_at") +%s) |
||||
|
new_date=$(date -d $(echo $CURRENT_RELEASE | jq -r ".updated_at") +%s) |
||||
|
if [ $new_date -gt $old_date ]; then |
||||
|
NEEDS_UPDATE=true |
||||
|
fi |
||||
|
fi |
||||
|
} |
||||
|
update_ui() { |
||||
|
printf '\nDownloading qBittorrent webui to "/vuetorrent"..please wait\n' |
||||
|
curl -L $(echo $CURRENT_RELEASE | jq -r ".browser_download_url") --output /tmp/vuetorrent.zip |
||||
|
printf '\nDownload finished\n\n' |
||||
|
if [[ -d /vuetorrent ]]; then |
||||
|
rm -rf /vuetorrent |
||||
|
fi |
||||
|
# mkdir -p /vuetorrent |
||||
|
unzip -q /tmp/vuetorrent.zip -d / |
||||
|
echo $CURRENT_RELEASE >"${RELEASE_FILEPATH}" |
||||
|
} |
||||
|
# =============================================== |
||||
|
|
||||
|
echo '-----------------------------------------' |
||||
|
echo '| qBittorrent vuetorrent theme.park Mod |' |
||||
|
echo '-----------------------------------------' |
||||
|
|
||||
|
if [[ -z ${TP_HOTIO} ]]; then |
||||
|
check_updates |
||||
|
|
||||
|
if [ "$NEEDS_UPDATE" = true ]; then |
||||
|
echo '---------------------------------------' |
||||
|
echo '| Downloading WebUI files from github |' |
||||
|
echo '---------------------------------------' |
||||
|
update_ui |
||||
|
else |
||||
|
echo ' WebUI files are up-to-date!' |
||||
|
fi |
||||
|
|
||||
|
if ! grep -q "WebUI\\\RootFolder" "${APP_FILEPATH}"; then |
||||
|
echo '--------------------------------------' |
||||
|
echo '| Adding WebUI\RootFolder=/vuetorrent |' |
||||
|
echo '--------------------------------------' |
||||
|
sed -i -e '$aWebUI\\RootFolder=/vuetorrent' "${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=/vuetorrent" "${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=\/vuetorrent/g" "${APP_FILEPATH}" |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
# Adding stylesheets |
||||
|
if ! grep -q "${TP_DOMAIN}/css/base" "${INDEX_FILEPATH}"; then |
||||
|
echo '---------------------------------------------------------' |
||||
|
echo '| Adding the stylesheet to /vuetorrent/public/index.html |' |
||||
|
echo '---------------------------------------------------------' |
||||
|
sed -i "s/<\/body>/<link rel='stylesheet' href='${TP_SCHEME}:\/\/${TP_DOMAIN}\/css\/base\/vuetorrent\/vuetorrent-base.css'><\/body> /g" "${INDEX_FILEPATH}" |
||||
|
sed -i "s/<\/body>/<link rel='stylesheet' href='${TP_SCHEME}:\/\/${TP_DOMAIN}\/css\/${THEME_TYPE}\/${TP_THEME}.css'><\/body> /g" "${INDEX_FILEPATH}" |
||||
|
printf 'Stylesheet set to %s on public index.html\n' "${TP_THEME}" |
||||
|
fi |
@ -0,0 +1 @@ |
|||||
|
oneshot |
@ -0,0 +1 @@ |
|||||
|
/etc/s6-overlay/s6-rc.d/init-mod-themepark/run |
Loading…
Reference in new issue