#!/bin/bash

## Copyright (C) 2012 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
shopt -s inherit_errexit
shopt -s shift_verbose
export LC_ALL=C

# shellcheck source=../../../../helper-scripts/usr/libexec/helper-scripts/light_sleep.bsh
source "${HELPER_SCRIPTS_PATH:-}"/usr/libexec/helper-scripts/light_sleep.bsh

## sets: systemd_notify
# shellcheck source=../../../../helper-scripts/usr/libexec/helper-scripts/systemd-notify.bsh
source "${HELPER_SCRIPTS_PATH:-}"/usr/libexec/helper-scripts/systemd-notify.bsh

## systemd_notify is assigned by the sourced systemd-notify.bsh above.
# shellcheck disable=SC2154
"${systemd_notify[@]}" --pid="$$" --ready

while true; do
   printf '%s\n' "$0: INFO: start."
   "${systemd_notify[@]}" --pid="$$" WATCHDOG=1

   /usr/libexec/systemcheck/canary

   "${systemd_notify[@]}" --pid="$$" WATCHDOG=1
   printf '%s\n' "$0: INFO: end."

   ## 1 hour
   light_sleep 3600
done
