]>
git.ipfire.org Git - thirdparty/dracut.git/blob - 51-dracut-rescue.install
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 [[ ${KERNEL_INSTALL_MACHINE_ID+x} ]]; then
37 MACHINE_ID
=$KERNEL_INSTALL_MACHINE_ID
38 elif [[ -f /etc
/machine-id
]] ; then
39 read MACHINE_ID
< /etc
/machine-id
42 if ! [[ $MACHINE_ID ]]; then
46 if [[ -f /etc
/kernel
/cmdline
]]; then
47 read -r -d '' -a BOOT_OPTIONS
< /etc
/kernel
/cmdline
48 elif [[ -f /usr
/lib
/kernel
/cmdline
]]; then
49 read -r -d '' -a BOOT_OPTIONS
< /usr
/lib
/kernel
/cmdline
52 if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
53 read -r -d '' -a line
< /proc
/cmdline
54 for i
in "${line[@]}"; do
55 [[ "${i#initrd=*}" != "$i" ]] && continue
60 if ! [[ ${BOOT_OPTIONS[*]} ]]; then
61 echo "Could not determine the kernel command line parameters." >&2
62 echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2
66 if [[ -d "${BOOT_DIR_ABS%/*}" ]]; then
67 BOOT_DIR
="/${MACHINE_ID}/0-rescue"
68 BOOT_ROOT
=${BOOT_DIR_ABS%$BOOT_DIR}
69 LOADER_ENTRY
="$BOOT_ROOT/loader/entries/${MACHINE_ID}-0-rescue.conf"
73 BLS_DIR
="/boot/loader/entries"
75 LOADER_ENTRY
="$BLS_DIR/${MACHINE_ID}-0-rescue.conf"
76 KERNEL
="vmlinuz-0-rescue-${MACHINE_ID}"
77 INITRD
="initramfs-0-rescue-${MACHINE_ID}.img"
84 [[ -f "$LOADER_ENTRY" ]] && [[ -f "$BOOT_DIR_ABS/$KERNEL" ]] \
85 && [[ -f "$BOOT_DIR_ABS/$INITRD" ]] && exit 0
87 # source our config dir
88 for f
in $
(dropindirs_sort
".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
92 [[ $dracut_rescue_image != "yes" ]] && exit 0
94 [[ -d "$BOOT_DIR_ABS" ]] || mkdir
-p "$BOOT_DIR_ABS"
96 if ! cp --reflink=auto
"$KERNEL_IMAGE" "$BOOT_DIR_ABS/$KERNEL"; then
97 echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/$KERNEL'!" >&2
100 if [[ ! -f "$BOOT_DIR_ABS/$INITRD" ]]; then
101 dracut
--no-hostonly -a "rescue" "$BOOT_DIR_ABS/$INITRD" "$KERNEL_VERSION"
105 if [[ "${BOOT_DIR_ABS}" != "/boot" ]]; then
107 echo "title $PRETTY_NAME - Rescue Image"
108 echo "version $KERNEL_VERSION"
109 echo "machine-id $MACHINE_ID"
110 echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
111 echo "linux $BOOT_DIR/linux"
112 echo "initrd $BOOT_DIR/initrd"
115 cp -aT "${KERNEL_IMAGE%/*}/bls.conf" $LOADER_ENTRY
116 sed -i 's/'$KERNEL_VERSION'/0-rescue-'${MACHINE_ID}'/' $LOADER_ENTRY