From 2268a6ecb1b39b84dd3ee847f4b1c25994f62742 Mon Sep 17 00:00:00 2001 From: GilbN Date: Sat, 16 Apr 2022 12:42:43 +0200 Subject: [PATCH 1/3] Adds mod for SWAG --- docker-mods/swag/Dockerfile | 6 ++ .../swag/root/etc/cont-init.d/98-themepark | 68 +++++++++++++++++++ .../swag/root/themepark.subdomain.conf | 30 ++++++++ .../swag/root/themepark.subfolder.conf | 17 +++++ 4 files changed, 121 insertions(+) create mode 100644 docker-mods/swag/Dockerfile create mode 100644 docker-mods/swag/root/etc/cont-init.d/98-themepark create mode 100644 docker-mods/swag/root/themepark.subdomain.conf create mode 100644 docker-mods/swag/root/themepark.subfolder.conf diff --git a/docker-mods/swag/Dockerfile b/docker-mods/swag/Dockerfile new file mode 100644 index 00000000..2c6713eb --- /dev/null +++ b/docker-mods/swag/Dockerfile @@ -0,0 +1,6 @@ +FROM scratch + +LABEL maintainer="GilbN" +LABEL app="theme-park.dev" +#copy local files. +COPY root/ / \ No newline at end of file diff --git a/docker-mods/swag/root/etc/cont-init.d/98-themepark b/docker-mods/swag/root/etc/cont-init.d/98-themepark new file mode 100644 index 00000000..e40f4664 --- /dev/null +++ b/docker-mods/swag/root/etc/cont-init.d/98-themepark @@ -0,0 +1,68 @@ +#!/usr/bin/with-contenv bash + +echo '-------------------------' +echo '| SWAG theme.park Mod |' +echo '-------------------------' + +if ! [[ -x "$(command -v svn)" ]]; then +echo '--------------------------' +echo '| Installing svn package |' +echo '--------------------------' + 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 +fi + +# 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 /root/themepark.subdomain.conf /config/nginx/proxy-confs/themepark.subdomain.conf +cp /root/themepark.subfolder.conf /config/nginx/proxy-confs/themepark.subfolder.conf + +# permissions +chown -R abc:abc \ + /config/www/themepark \ No newline at end of file diff --git a/docker-mods/swag/root/themepark.subdomain.conf b/docker-mods/swag/root/themepark.subdomain.conf new file mode 100644 index 00000000..b5fdca9a --- /dev/null +++ b/docker-mods/swag/root/themepark.subdomain.conf @@ -0,0 +1,30 @@ +server { + listen 443 ssl; + listen [::]:443 ssl; + + server_name themepark.*; + + include /config/nginx/ssl.conf; + + index index.html index.htm index.php; + + location / { + alias /config/www/themepark/; + try_files $uri $uri/ /index.html; + } + location /themepark {return 302 $scheme://$http_host/themepark/;} + location /themepark/ { + alias /config/www/themepark/; + sub_filter_types *; + sub_filter 'url("/css/' 'url("/themepark/css/'; + sub_filter_once off; + try_files $uri $uri/ /index.html; + } + + # Don't cache + add_header Last-Modified $date_gmt; + add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; + if_modified_since off; + expires -1; + etag off; +} diff --git a/docker-mods/swag/root/themepark.subfolder.conf b/docker-mods/swag/root/themepark.subfolder.conf new file mode 100644 index 00000000..daf97ddc --- /dev/null +++ b/docker-mods/swag/root/themepark.subfolder.conf @@ -0,0 +1,17 @@ + location /themepark { + return 302 $scheme://$http_host/themepark/; + } + + location /themepark/ { + alias /config/www/themepark/; + sub_filter_types *; + sub_filter 'url("/css/' 'url("/themepark/css/'; + sub_filter_once off; + try_files $uri $uri/ /index.html; + # Don't cache + add_header Last-Modified $date_gmt; + add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; + if_modified_since off; + expires -1; + etag off; + } From dca301ff454754fbc1d82859f7a754439262ee46 Mon Sep 17 00:00:00 2001 From: GilbN Date: Sat, 16 Apr 2022 12:48:02 +0200 Subject: [PATCH 2/3] path to nginx conf fix --- docker-mods/swag/root/etc/cont-init.d/98-themepark | 4 ++-- .../swag/root/{ => themepark-confs}/themepark.subdomain.conf | 0 .../swag/root/{ => themepark-confs}/themepark.subfolder.conf | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename docker-mods/swag/root/{ => themepark-confs}/themepark.subdomain.conf (100%) rename docker-mods/swag/root/{ => themepark-confs}/themepark.subfolder.conf (100%) diff --git a/docker-mods/swag/root/etc/cont-init.d/98-themepark b/docker-mods/swag/root/etc/cont-init.d/98-themepark index e40f4664..f9a3e3df 100644 --- a/docker-mods/swag/root/etc/cont-init.d/98-themepark +++ b/docker-mods/swag/root/etc/cont-init.d/98-themepark @@ -60,8 +60,8 @@ if [[ $SHA != $SHA_RELEASE ]]; then fi cat <<< "$SHA_RELEASE" > "/config/www/themepark/sha.txt" -cp /root/themepark.subdomain.conf /config/nginx/proxy-confs/themepark.subdomain.conf -cp /root/themepark.subfolder.conf /config/nginx/proxy-confs/themepark.subfolder.conf +cp /themepark-confs/themepark.subdomain.conf /config/nginx/proxy-confs/themepark.subdomain.conf +cp /themepark-confs/themepark.subfolder.conf /config/nginx/proxy-confs/themepark.subfolder.conf # permissions chown -R abc:abc \ diff --git a/docker-mods/swag/root/themepark.subdomain.conf b/docker-mods/swag/root/themepark-confs/themepark.subdomain.conf similarity index 100% rename from docker-mods/swag/root/themepark.subdomain.conf rename to docker-mods/swag/root/themepark-confs/themepark.subdomain.conf diff --git a/docker-mods/swag/root/themepark.subfolder.conf b/docker-mods/swag/root/themepark-confs/themepark.subfolder.conf similarity index 100% rename from docker-mods/swag/root/themepark.subfolder.conf rename to docker-mods/swag/root/themepark-confs/themepark.subfolder.conf From 67f0cd005090bc10e6c9c5f67cde0c3428900c8b Mon Sep 17 00:00:00 2001 From: GilbN Date: Sat, 16 Apr 2022 14:33:07 +0200 Subject: [PATCH 3/3] rename to .sample --- docker-mods/swag/root/etc/cont-init.d/98-themepark | 3 +-- ...hemepark.subdomain.conf => themepark.subdomain.conf.sample} | 0 ...hemepark.subfolder.conf => themepark.subfolder.conf.sample} | 0 3 files changed, 1 insertion(+), 2 deletions(-) rename docker-mods/swag/root/themepark-confs/{themepark.subdomain.conf => themepark.subdomain.conf.sample} (100%) rename docker-mods/swag/root/themepark-confs/{themepark.subfolder.conf => themepark.subfolder.conf.sample} (100%) diff --git a/docker-mods/swag/root/etc/cont-init.d/98-themepark b/docker-mods/swag/root/etc/cont-init.d/98-themepark index f9a3e3df..3c838be1 100644 --- a/docker-mods/swag/root/etc/cont-init.d/98-themepark +++ b/docker-mods/swag/root/etc/cont-init.d/98-themepark @@ -60,8 +60,7 @@ if [[ $SHA != $SHA_RELEASE ]]; then fi cat <<< "$SHA_RELEASE" > "/config/www/themepark/sha.txt" -cp /themepark-confs/themepark.subdomain.conf /config/nginx/proxy-confs/themepark.subdomain.conf -cp /themepark-confs/themepark.subfolder.conf /config/nginx/proxy-confs/themepark.subfolder.conf +cp /themepark-confs/* /config/nginx/proxy-confs # permissions chown -R abc:abc \ diff --git a/docker-mods/swag/root/themepark-confs/themepark.subdomain.conf b/docker-mods/swag/root/themepark-confs/themepark.subdomain.conf.sample similarity index 100% rename from docker-mods/swag/root/themepark-confs/themepark.subdomain.conf rename to docker-mods/swag/root/themepark-confs/themepark.subdomain.conf.sample diff --git a/docker-mods/swag/root/themepark-confs/themepark.subfolder.conf b/docker-mods/swag/root/themepark-confs/themepark.subfolder.conf.sample similarity index 100% rename from docker-mods/swag/root/themepark-confs/themepark.subfolder.conf rename to docker-mods/swag/root/themepark-confs/themepark.subfolder.conf.sample