exit if lockfile present

This commit is contained in:
Paolo Asperti 2024-10-14 17:27:44 +02:00
parent 1e3638d474
commit 359d346c33
Signed by: paspo
GPG Key ID: 06D46905D19D5182

View File

@ -1,6 +1,7 @@
#!/bin/bash
CONF=/etc/btrbk/btrbk-cron.conf
LOCKFILE=/run/btrbk/btrbk.lock
LOGFILE=$(mktemp)
trap 'rm -f -- "${LOGFILE}"' EXIT
@ -29,6 +30,15 @@ else
echo "Info: Healthchecks disabled"
fi
if [[ -f "${LOCKFILE}" ]] ; then
echo "Another instance is still running" | tee -a "${LOGFILE}"
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log"
fi
rm -f -- "${LOGFILE}"
exit 0
fi
HOST=$(grep -E '^[\ \t]*target[\ \t]+send-receive' /etc/btrbk/btrbk.conf)
# TODO: support for dashes in hostname and IPv6 ("[2001:db8::7]")
HOST=$(echo "${HOST}" | sed -r 's/.*ssh:\/\/([0-9\.a-zA-Z]+).*/\1/g' )