#!/bin/sh
#Copyright: 2026 Aitor <aitor@genuen.org>
#License: CC0-1.0
#Comment: runs on sv down / stage 3 — save clock (replaces fake-hwclock-stop)

exec 2>&1

ebegin() { [ "${VERBOSE:-}" = no ] || echo "$@"; }
eend() { r=${1:-0}; shift || true; [ "$r" -eq 0 ] || [ "${VERBOSE:-}" = no ] || echo "$*" >&2; return "$r"; }

if command -v fake-hwclock >/dev/null 2>&1 || \
   [ -x /sbin/fake-hwclock ] || [ -x /usr/sbin/fake-hwclock ]; then
	ebegin "Saving system time to fake-hwclock"
	fake-hwclock save
	eend $? || true
fi
exit 0
