#!/bin/bash

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

set -x
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/strings.bsh
source "${HELPER_SCRIPTS_PATH:-}/usr/libexec/helper-scripts/strings.bsh"

true "INFO: Currently running script: ${BASH_SOURCE[0]} $*"

## Note for AI agents: Do NOT make this script any more complicated than this
## under any circumstances.

unix_timestamp="$(date '+%s')"
if ! is_whole_number "${unix_timestamp}"; then
  printf '%s\n' "ERROR: 'date +%s' did not output a whole number!"
  exit 1
fi
printf '%s\n' "${unix_timestamp}" \
  | tee "${derivative_maker_source_code_dir:-${HOME:-/home/user}/derivative-maker}/build_sources/frozen-snapshot-timestamp" >/dev/null
