2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
9 BOOT_DIR_ABS
="${3%/*}/0-rescue"
18 while (( $# > 0 )); do
19 for i
in ${1}/*${suffix}; do
20 [[ -f $i ]] && echo ${i##*/}
27 for d
in "${args[@]}"; do
28 if [[ -f "$d/$f" ]]; then
36 [[ -f /etc
/os-release
]] && .
/etc
/os-release
38 if [[ ! -f /etc
/machine-id
]] ||
[[ ! -s /etc
/machine-id
]]; then
39 systemd-machine-id-setup
42 [[ -f /etc
/machine-id
]] && read MACHINE_ID
< /etc
/machine-id
44 if [[ -f /etc
/kernel
/cmdline
]]; then
45 readarray
-t BOOT_OPTIONS
< /etc
/kernel
/cmdline
47 if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
48 readarray
-t BOOT_OPTIONS
< /proc
/cmdline
50 if ! [[ $BOOT_OPTIONS ]]; then
54 LOADER_ENTRY
="/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"
55 BOOT_DIR
="/${MACHINE_ID}/0-rescue"
61 for i
in "/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"; do
65 # source our config dir
66 for f
in $
(dropindirs_sort
".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
70 [[ $dracut_rescue_image != "yes" ]] && exit 0
72 [[ -d "$BOOT_DIR_ABS" ]] || mkdir
-p "$BOOT_DIR_ABS"
74 if ! cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS"/linux
; then
75 echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'!" >&2
78 dracut
--no-hostonly -a "rescue" "$BOOT_DIR_ABS"/initrd
"$2"
82 echo "title $PRETTY_NAME - Rescue Image"
83 echo "version $KERNEL_VERSION"
84 echo "machine-id $MACHINE_ID"
85 echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
86 echo "linux $BOOT_DIR/linux"
87 echo "initrd $BOOT_DIR/initrd"