7 BOOT_DIR_ABS
="${3%/*}/0-rescue"
16 while (( $# > 0 )); do
17 for i
in ${1}/*${suffix}; do
18 [[ -f $i ]] && echo ${i##*/}
25 for d
in "${args[@]}"; do
26 if [[ -f "$d/$f" ]]; then
34 [[ -f /etc
/os-release
]] && .
/etc
/os-release
36 if [[ ! -f /etc
/machine-id
]] ||
[[ ! -s /etc
/machine-id
]]; then
37 systemd-machine-id-setup
40 [[ -f /etc
/machine-id
]] && read MACHINE_ID
< /etc
/machine-id
42 if [[ -f /etc
/kernel
/cmdline
]]; then
43 read -r -d '' -a BOOT_OPTIONS
< /etc
/kernel
/cmdline
44 elif [[ -f /usr
/lib
/kernel
/cmdline
]]; then
45 read -r -d '' -a BOOT_OPTIONS
< /usr
/lib
/kernel
/cmdline
48 if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
49 read -r -d '' -a line
< /proc
/cmdline
50 for i
in "${line[@]}"; do
51 [[ "${i#initrd=*}" != "$i" ]] && continue
56 if ! [[ ${BOOT_OPTIONS[*]} ]]; then
57 echo "Could not determine the kernel command line parameters." >&2
58 echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2
62 LOADER_ENTRY
="/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"
63 BOOT_DIR
="/${MACHINE_ID}/0-rescue"
69 for i
in "/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"; do
73 # source our config dir
74 for f
in $
(dropindirs_sort
".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
78 [[ $dracut_rescue_image != "yes" ]] && exit 0
80 [[ -d "$BOOT_DIR_ABS" ]] || mkdir
-p "$BOOT_DIR_ABS"
82 if ! cp --reflink=auto
"$KERNEL_IMAGE" "$BOOT_DIR_ABS"/linux
; then
83 echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'!" >&2
86 dracut
--no-hostonly -a "rescue" "$BOOT_DIR_ABS"/initrd
"$KERNEL_VERSION"
90 echo "title $PRETTY_NAME - Rescue Image"
91 echo "version $KERNEL_VERSION"
92 echo "machine-id $MACHINE_ID"
93 echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
94 echo "linux $BOOT_DIR/linux"
95 echo "initrd $BOOT_DIR/initrd"