1#!/bin/sh 2# shellcheck disable=SC2016,SC1004,SC2154 3 4grep -wq debug /proc/cmdline && debug=1 5[ -n "$debug" ] && echo "zfs-generator: starting" >> /dev/kmsg 6 7GENERATOR_DIR="$1" 8[ -n "$GENERATOR_DIR" ] || { 9 echo "zfs-generator: no generator directory specified, exiting" >> /dev/kmsg 10 exit 1 11} 12 13# shellcheck source=zfs-lib.sh.in 14. /lib/dracut-zfs-lib.sh 15decode_root_args || exit 0 16 17[ -n "$debug" ] && echo "zfs-generator: writing extension for sysroot.mount to $GENERATOR_DIR/sysroot.mount.d/zfs-enhancement.conf" >> /dev/kmsg 18 19 20mkdir -p "$GENERATOR_DIR"/sysroot.mount.d "$GENERATOR_DIR"/dracut-pre-mount.service.d 21 22{ 23 echo "[Unit]" 24 echo "Before=initrd-root-fs.target" 25 echo "After=zfs-import.target" 26 echo 27 echo "[Mount]" 28 echo "PassEnvironment=BOOTFS BOOTFSFLAGS" 29 echo 'What=${BOOTFS}' 30 echo "Type=zfs" 31 echo 'Options=${BOOTFSFLAGS}' 32} > "$GENERATOR_DIR"/sysroot.mount.d/zfs-enhancement.conf 33ln -fs ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount 34 35{ 36 echo "[Unit]" 37 echo "After=zfs-import.target" 38} > "$GENERATOR_DIR"/dracut-pre-mount.service.d/zfs-enhancement.conf 39 40[ -n "$debug" ] && echo "zfs-generator: finished" >> /dev/kmsg 41 42exit 0 43