#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
#
# initramfs-tools boot script: attach before the root filesystem is mounted.
#
# Installed as /usr/share/initramfs-tools/scripts/local-top/scradle. The
# local-top stage runs after udev has settled the block devices and before
# `local_mount_root`, so the mount of the root filesystem, its journal replay
# after an unclean stop, and every write either of them makes are inside the
# tracked window rather than in front of it.
#
# PREREQ is empty on purpose: this must run as early in local-top as the
# stage allows. Ordering it after anything else would only widen the window
# it exists to narrow.
#
# There is no `set -e` and no failure path that returns non-zero. A boot
# script that exits non-zero drops the machine into the initramfs shell, and
# a backup driver that can do that is worse than no backup driver. The
# helper's own policy is written at the top of /sbin/scradle-boot-attach.

PREREQ=""
prereqs() { echo "$PREREQ"; }
case "${1:-}" in
prereqs)
	prereqs
	exit 0
	;;
esac

[ -x /sbin/scradle-boot-attach ] && /sbin/scradle-boot-attach
exit 0
