Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom HTML template #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
@@ -1,4 +1,4 @@
FROM busybox
FROM busybox:musl
LABEL maintainer="Yusuph Wickama <yusuph.wickama@wickerlabs.com>"
COPY html/index.html entrypoint.sh /
ENV MESSAGE="Sorry for the inconvenience but we\&rsquo;re performing some maintenance at the moment. If you need to you can always <a href=\"mailto:{{mail}}\">{{contact}}<\/a>, otherwise we\&rsquo;ll be back online shortly!"
Expand All @@ -11,4 +11,4 @@ ENV LINK_COLOR="#dc8100"
ENV THEME="Light"
ENV RESPONSE_CODE="503 Service Unavailable"
ENV CONTACT_LINK="contact us"
ENTRYPOINT [ "./entrypoint.sh" ]
ENTRYPOINT [ "./entrypoint.sh" ]
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -34,6 +34,7 @@ This image came as a result for the need to place a simple maintenance page in t
|`THEME`|Modifies page theme current options `Light` or `Dark`. Defaults to `Light`
|`RESPONSE_CODE`| Specifies the HTTP response code to serve with the maintenance page. Defaults to `503 Service Unavailable` |
|`PORT`| Specifies the port to serve the maintenance page. Defaults to `8080` |
|`HTML`| Specifies custom maintenance page HTML template. Defaults [index.html](html/index.html) |

## Docker
You can easily run or create a docker container for this [image](https://hub.docker.com/r/wickerlabs/maintenance) by using the command:
Expand Down
18 changes: 10 additions & 8 deletions entrypoint.sh
@@ -1,10 +1,12 @@
#! /bin/sh
sed -i "s/{{message}}/$(echo ${MESSAGE})/g" index.html
sed -i "s/{{contact}}/$(echo ${CONTACT_LINK})/g" index.html
sed -i "s/{{mail}}/$(echo ${MAIL_ADDRESS})/g" index.html
sed -i "s/{{headline}}/$(echo ${HEADLINE})/g" index.html
sed -i "s/{{team_name}}/$(echo ${TEAM_NAME})/g" index.html
sed -i "s/{{title}}/$(echo ${TITLE})/g" index.html
sed -i "s/{{theme}}/$(echo ${THEME})/g" index.html

while true; do { echo -e "HTTP/1.1 ${RESPONSE_CODE}\r\n"; echo "$(cat index.html)"; } | nc -lvp "$PORT"; done
RESPONSE=`echo "HTTP/1.1 ${RESPONSE_CODE}\n\n ${HTML:=\`cat index.html\`}" | \
sed "s/{{message}}/$(echo ${MESSAGE})/g" | \
sed "s/{{contact}}/$(echo ${CONTACT_LINK})/g" | \
sed "s/{{mail}}/$(echo ${MAIL_ADDRESS})/g" | \
sed "s/{{headline}}/$(echo ${HEADLINE})/g" | \
sed "s/{{team_name}}/$(echo ${TEAM_NAME})/g" | \
sed "s/{{title}}/$(echo ${TITLE})/g" | \
sed "s/{{theme}}/$(echo ${THEME})/g"`

while true; do printf "$RESPONSE" | nc -lzp "$PORT"; done