## ## /etc/rc.d/functions.d/hooks ## ## Run `grep run_hook /etc/rc.*` to list the available hooks. See ## /etc/rc.d/functions for detailed usage. ## Directory where to mount the cryptkey device. CRYPTKEY_DIR="/media/keys" ## Mount the device specified in the cryptkey kernel command line argument to ## CRYPTKEY_DIR. mount_cryptkey_device() { ## Do not write to /etc/mtab as the root filesystem is mounted read-only. /bin/mount -n -o ro "$(/bin/sed -n -r 's/^[[:space:]]*([^[:space:]]+[[:space:]]+)*cryptkey=([^:[:space:]]+)(:[^:[:space:]]+){2}([[:space:]]+[^[:space:]]+)*[[:space:]]*$/\2/p' \ /proc/cmdline | /usr/bin/tail -n 1)" "$CRYPTKEY_DIR" } add_hook sysinit_udevsettled mount_cryptkey_device ## Unmount the device mounted on CRYPTKEY_DIR. unmount_cryptkey_device() { ## No `-n`, as in the meantime /etc/mtab was repopulated by findmnt(8) and ## the root filesystem is now writeable. /bin/umount "$CRYPTKEY_DIR" } add_hook sysinit_premount unmount_cryptkey_device ## vim: filetype=sh