diff --git a/btrbk-cron b/btrbk-cron index c96fab6..4d7c865 100755 --- a/btrbk-cron +++ b/btrbk-cron @@ -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' )