Skip to content

Commit 3271177

Browse files
allow for initialization phase
1 parent 61bd8fc commit 3271177

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
#!/bin/bash
22
echo "[II] qnib/init-plain script v0.4.23"
33
HEALTHCHECK_DIR=${HEALTHCHECK_DIR:-/opt/healthchecks/}
4-
set -e
4+
set -e
5+
ERRORCODES=0
56

67
if [[ ! -d ${HEALTHCHECK_DIR} ]];then
78
echo "> No healthcheck dir found '${HEALTHCHECK_DIR}'"
89
exit 0
910
fi
1011
if [[ "X${ALLOW_HEALTHCHECK_OVERWRITE}" == "Xtrue" ]] && [[ -f ${HEALTHCHECK_DIR}/force_true ]];then
11-
echo "> Healthcheck is set to OK via '${HEALTHCHECK_DIR}/force_true' and ALLOW_HEALTHCHECK_OVERWRITE=true"
12-
exit 0
12+
echo ">> INITIALIZATION PHASE! Until HC successed the first time, it will be overwritten to be OK."
13+
set +e
1314
fi
14-
while read -r line;do
15+
while read -r line;do
1516
echo "> execute healthcheck '${x}'"
1617
${x}
18+
EC=$?
19+
if [[ ${EC} -ne 0 ]];then
20+
echo ">> Healthcheck failed, but as '${HEALTHCHECK_DIR}/force_true' is set it will be ignored"
21+
fi
22+
ERRORCODES+=$EC
1723
done <<< $(find ${HEALTHCHECK_DIR} -type f -perm /u+x |sort)
24+
if [[ ${ERRORCODES} == 0 ]];then
25+
echo "> INITIALIZATION stops, removing ''${HEALTHCHECK_DIR}/force_true'"
26+
rm -f ${HEALTHCHECK_DIR}/force_true
27+
fi
1828
exit 0

0 commit comments

Comments
 (0)