haproxy-errpages/Makefile

21 lines
598 B
Makefile

HTTP_TEMPLATE := template
CODES_LIST := codes.json
LOGO := logo.png
CODES := $(shell jq -r '. | keys[]' < "${CODES_LIST}")
ALL_TARGETS := $(addsuffix .http,${CODES})
all: ${ALL_TARGETS}
${CODES_LIST}:
curl -L https://status.js.org/codes.json -o $@
clean:
-rm -rv ${ALL_TARGETS}
%.http: ${HTTP_TEMPLATE} ${CODES_LIST}
sed \
-e "s|TMPL_ERROR_NAME|$$(jq -r '.["${*}"].message' < ${CODES_LIST})|g" \
-e "s|TMPL_ERROR_DESCRIPTION|$$(jq -r '.["${*}"].description' < ${CODES_LIST})|g" \
-e "s|TMPL_LOGO_BASE64|$$(base64 -w0 ${LOGO})|g" \
-e "s|TMPL_ERROR_CODE|${*}|g" ${HTTP_TEMPLATE} > $@