From a178b072ff13b5a704cb9c592d8c6f0dfdf981f7 Mon Sep 17 00:00:00 2001 From: Jafner <40403594+Jafner@users.noreply.github.com> Date: Mon, 5 Jul 2021 00:01:04 -0700 Subject: [PATCH] Initial commit A functional initial release --- 5etools-docker/Dockerfile | 9 +++++++ 5etools-docker/init.sh | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 5etools-docker/Dockerfile create mode 100644 5etools-docker/init.sh diff --git a/5etools-docker/Dockerfile b/5etools-docker/Dockerfile new file mode 100644 index 00000000..f7bdbf2c --- /dev/null +++ b/5etools-docker/Dockerfile @@ -0,0 +1,9 @@ +FROM httpd +COPY init.sh /init.sh +RUN apt-get update && \ +apt-get upgrade && \ +apt-get -y install curl p7zip-full +WORKDIR /usr/local/apache2/htdocs/ +RUN mkdir download +ENV IMG false +CMD ["/bin/bash","/init.sh"] diff --git a/5etools-docker/init.sh b/5etools-docker/init.sh new file mode 100644 index 00000000..baf822a8 --- /dev/null +++ b/5etools-docker/init.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# based on: https://wiki.5e.tools/index.php/5eTools_Install_Guide +FN=`curl -s -k -I https://get.5e.tools/src/|grep filename|cut -d"=" -f2 | awk '{print $1}'` # get filename of most recent version +FN=${FN//[$'\t\r\n"']} # remove quotes +echo "FN: $FN" +FN_IMG=`curl -s -k -I https://get.5e.tools/img/|grep filename|cut -d"=" -f2 | awk '{print $1}'` # get filename of most recent image pack +FN_IMG=${FN_IMG//[$'\t\r\n"']} # remove quotes +echo "FN_IMG: $FN_IMG" +VER=`basename ${FN} ".zip"|sed 's/5eTools\.//'` # get version number +echo "VER: $VER" +CUR=$( version + + rm ./index.html 2> /dev/null || true + + echo " === Downloading new remote version..." + cd ./download/ + curl --progress-bar -k -O -J https://get.5e.tools/src/ -C - + + if [ "$IMG" = "true" ]; then + curl --progress-bar -k -O -J https://get.5e.tools/img/ -C - + fi + cd .. + + echo " === Extracting site..." + 7z x ./download/$FN -o./ -y + + if [ "$IMG" = "true" ]; then + echo " === Extracting images..." + 7z x ./download/$FN_IMG -o./img -y + mv ./img/tmp/5et/img/* ./img + rm -r ./img/tmp + fi + + echo " === Configuring..." + find . -name \*.html -exec sed -i 's/"width=device-width, initial-scale=1"/"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/' {} \; + cp 5etools.html index.html + sed -i 's//\n/' index.html + sed -i 's/navigator.serviceWorker.register("\/sw.js/navigator.serviceWorker.register("sw.js/' index.html + sed -i 's/navigator.serviceWorker.register("\/sw.js/navigator.serviceWorker.register("sw.js/' 5etools.html + + echo " === Cleaning up downloads" + find ./download/ -type f ! -name "*.${VER}.zip" -exec rm {} + + + echo " === Done!" +else + echo " === Local version matches remote, no action." +fi + +httpd-foreground \ No newline at end of file