#!/usr/bin/bash
# SPDX-License-Identifier: MIT
set -euo pipefail

[[ -e /etc/initrd-release ]] || exit 0
case " $(</proc/cmdline) " in
    *' image.installer=yes '*) exit 0 ;;
esac

# No dependency on installed USER mounts is pulled into the live environment.
# Installed boots must mount their versioned /etc before switching root.
# sysroot-etc.mount pulls in image-etc-prepare.service, which requires the
# native sysroot-.system.mount.
for unit in initrd-parse-etc.service initrd-switch-root.target; do
    install -d -m 0755 "${1}/${unit}.requires"
    ln -sf /usr/lib/systemd/system/sysroot-etc.mount \
        "${1}/${unit}.requires/sysroot-etc.mount"
done
