#!/usr/bin/ash
# shellcheck shell=dash

cryptname="${1}"

# Start udev from initramfs
/usr/lib/systemd/systemd-udevd --daemon --resolve-names=never

# Synchronize filesystems before luksSuspend
sync

# Suspend root device
[ -z "$cryptname" ] || cryptsetup luksSuspend "$cryptname"

# Suspend the system
echo mem >/sys/power/state

# Resume root device
export YKFDE_RESUME=1

# shellcheck source=/dev/null
. /init_functions
parse_cmdline </proc/cmdline
# shellcheck source=hooks/ykfde
. /hooks/ykfde
run_hook

# Stop udev from initramfs, as the real daemon from rootfs will be restarted
udevadm control --exit
