From bbb14284a963a7d65d107149a0224beef36a9847 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 1 Mar 2021 21:28:26 -0800 Subject: [PATCH] Refactored 5etools --- docker_config/5etools/5etools-update.sh | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 docker_config/5etools/5etools-update.sh diff --git a/docker_config/5etools/5etools-update.sh b/docker_config/5etools/5etools-update.sh new file mode 100755 index 00000000..bdd5c541 --- /dev/null +++ b/docker_config/5etools/5etools-update.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# based on: https://wiki.5e.tools/index.php/5eTools_Install_Guide + +cd ${DOCKER_DATA}/5etools/htdocs + +FN=`curl -s -I https://get.5e.tools/release/|grep filename|cut -d"=" -f2 | awk '{print $1}'` +FN=${FN//[$'\t\r\n"']} +echo "FN: $FN" +FN_IMG=`curl -s -I https://get.5e.tools/img/|grep filename|cut -d"=" -f2 | awk '{print $1}'` +FN_IMG=${FN_IMG//[$'\t\r\n"']} +echo "FN_IMG: $FN_IMG" +VER=`basename ${FN} ".zip"|sed 's/5eTools\.//'` +echo "VER: $VER" +CUR=$( version + + rm ./index.html 2> /dev/null || true + + echo " === Downloading new remote version..." + cd ./download/ + curl --progress-bar -O -J https://get.5e.tools/release/ -C - + curl --progress-bar -O -J https://get.5e.tools/img/ -C - + cd .. + + echo " === Extracting site..." + 7z x ./download/$FN -o./ -y + echo " === Extracting images..." + 7z x ./download/$FN_IMG -o./img -y + mv ./img/tmp/5et/img/* ./img + rm -r ./img/tmp + + 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