Add healthcheck functionality
This commit is contained in:
parent
8b4cbe8a60
commit
c557895079
@ -1,9 +1,11 @@
|
|||||||
FROM httpd
|
FROM httpd
|
||||||
COPY init.sh /init.sh
|
COPY init.sh /init.sh
|
||||||
|
COPY healthcheck.sh /healthcheck.sh
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get -y upgrade && \
|
apt-get -y upgrade && \
|
||||||
apt-get -y install curl p7zip-full
|
apt-get -y install curl p7zip-full
|
||||||
WORKDIR /usr/local/apache2/htdocs/
|
WORKDIR /usr/local/apache2/htdocs/
|
||||||
RUN mkdir download
|
RUN mkdir download
|
||||||
ENV IMG false
|
ENV IMG false
|
||||||
CMD ["/bin/bash","/init.sh"]
|
HEALTHCHECK --startperiod=1m CMD /healthcheck.sh
|
||||||
|
CMD ["/bin/bash","/init.sh"]
|
||||||
8
healthcheck.sh
Normal file
8
healthcheck.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while [ $(cat /status) != "INIT" ]
|
||||||
|
do
|
||||||
|
sleep 10;
|
||||||
|
done
|
||||||
|
|
||||||
|
curl --insecure --fail --silent --show-error -I http://localhost:80 > /dev/null || exit 1
|
||||||
13
init.sh
13
init.sh
@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# based on: https://wiki.5e.tools/index.php/5eTools_Install_Guide
|
# based on: https://wiki.5e.tools/index.php/5eTools_Install_Guide
|
||||||
|
|
||||||
|
echo "STARTING" > /status
|
||||||
|
|
||||||
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=`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
|
FN=${FN//[$'\t\r\n"']} # remove quotes
|
||||||
echo "FN: $FN"
|
echo "FN: $FN"
|
||||||
@ -17,6 +20,7 @@ if [ "$VER" != "$CUR" ]
|
|||||||
then
|
then
|
||||||
echo " === Local version outdated, updating..."
|
echo " === Local version outdated, updating..."
|
||||||
echo -n $VER > version
|
echo -n $VER > version
|
||||||
|
echo "DOWNLOADING" > /status
|
||||||
|
|
||||||
rm ./index.html 2> /dev/null || true
|
rm ./index.html 2> /dev/null || true
|
||||||
|
|
||||||
@ -25,32 +29,41 @@ then
|
|||||||
curl --progress-bar -k -O -J https://get.5e.tools/src/ -C -
|
curl --progress-bar -k -O -J https://get.5e.tools/src/ -C -
|
||||||
|
|
||||||
if [ "$IMG" = "true" ]; then
|
if [ "$IMG" = "true" ]; then
|
||||||
|
echo " === Downloading images === "
|
||||||
|
echo "DOWNLOADING IMAGES" > /status
|
||||||
curl --progress-bar -k -O -J https://get.5e.tools/img/ -C -
|
curl --progress-bar -k -O -J https://get.5e.tools/img/ -C -
|
||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
echo " === Extracting site..."
|
echo " === Extracting site..."
|
||||||
|
echo "EXTRACTING" > /status
|
||||||
7z x ./download/$FN -o./ -y
|
7z x ./download/$FN -o./ -y
|
||||||
|
|
||||||
if [ "$IMG" = "true" ]; then
|
if [ "$IMG" = "true" ]; then
|
||||||
echo " === Extracting images..."
|
echo " === Extracting images..."
|
||||||
|
echo "EXTRACTING IMAGES" > /status
|
||||||
7z x ./download/$FN_IMG -o./img -y
|
7z x ./download/$FN_IMG -o./img -y
|
||||||
mv ./img/tmp/5et/img/* ./img
|
mv ./img/tmp/5et/img/* ./img
|
||||||
rm -r ./img/tmp
|
rm -r ./img/tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " === Configuring..."
|
echo " === Configuring..."
|
||||||
|
echo "CONFIGURING" > /status
|
||||||
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"/' {} \;
|
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/<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/' index.html
|
||||||
sed -i 's/navigator.serviceWorker.register("\/sw.js/navigator.serviceWorker.register("sw.js/' 5etools.html
|
sed -i 's/navigator.serviceWorker.register("\/sw.js/navigator.serviceWorker.register("sw.js/' 5etools.html
|
||||||
|
|
||||||
echo " === Cleaning up downloads"
|
echo " === Cleaning up downloads"
|
||||||
|
echo "CLEANING" > /status
|
||||||
find ./download/ -type f ! -name "*.${VER}.zip" -exec rm {} +
|
find ./download/ -type f ! -name "*.${VER}.zip" -exec rm {} +
|
||||||
|
|
||||||
echo " === Done!"
|
echo " === Done!"
|
||||||
|
echo "INIT" > /status
|
||||||
else
|
else
|
||||||
echo " === Local version matches remote, no action."
|
echo " === Local version matches remote, no action."
|
||||||
|
echo "INIT" > /status
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
httpd-foreground
|
httpd-foreground
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user