2021-07-05 00:01:04 -07:00
|
|
|
#!/bin/bash
|
|
|
|
# based on: https://wiki.5e.tools/index.php/5eTools_Install_Guide
|
2021-08-01 12:57:30 -07:00
|
|
|
|
|
|
|
echo "STARTING" > /status
|
|
|
|
|
2021-07-05 00:01:04 -07:00
|
|
|
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)
|
|
|
|
|
|
|
|
echo " === Remote version: $VER"
|
|
|
|
echo " === Local version: $CUR"
|
|
|
|
|
|
|
|
if [ "$VER" != "$CUR" ]
|
|
|
|
then
|
|
|
|
echo " === Local version outdated, updating..."
|
|
|
|
echo -n $VER > version
|
2021-08-01 12:57:30 -07:00
|
|
|
echo "DOWNLOADING" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
|
|
|
|
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
|
2021-08-01 12:57:30 -07:00
|
|
|
echo " === Downloading images === "
|
|
|
|
echo "DOWNLOADING IMAGES" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
curl --progress-bar -k -O -J https://get.5e.tools/img/ -C -
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo " === Extracting site..."
|
2021-08-01 12:57:30 -07:00
|
|
|
echo "EXTRACTING" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
7z x ./download/$FN -o./ -y
|
|
|
|
|
|
|
|
if [ "$IMG" = "true" ]; then
|
|
|
|
echo " === Extracting images..."
|
2021-08-01 12:57:30 -07:00
|
|
|
echo "EXTRACTING IMAGES" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
7z x ./download/$FN_IMG -o./img -y
|
|
|
|
mv ./img/tmp/5et/img/* ./img
|
|
|
|
rm -r ./img/tmp
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo " === Configuring..."
|
2021-08-01 12:57:30 -07:00
|
|
|
echo "CONFIGURING" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
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"/' {} \;
|
|
|
|
sed -i 's/<head>/<head>\n<link rel="apple-touch-icon" href="icon\/icon-512.png">/' 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"
|
2021-08-01 12:57:30 -07:00
|
|
|
echo "CLEANING" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
find ./download/ -type f ! -name "*.${VER}.zip" -exec rm {} +
|
|
|
|
|
|
|
|
echo " === Done!"
|
2021-08-01 12:57:30 -07:00
|
|
|
echo "INIT" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
else
|
|
|
|
echo " === Local version matches remote, no action."
|
2021-08-01 12:57:30 -07:00
|
|
|
echo "INIT" > /status
|
2021-07-05 00:01:04 -07:00
|
|
|
fi
|
|
|
|
|
2021-08-01 12:57:30 -07:00
|
|
|
|
2021-07-05 01:35:58 -07:00
|
|
|
httpd-foreground
|