2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
10 [[ -f /etc/os-release ]] && . /etc/os-release
12 if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
13 systemd-machine-id-setup
16 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
18 [[ $MACHINE_ID ]] || exit 1
19 [[ -f $KERNEL_IMAGE ]] || exit 1
21 INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
22 NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
24 [[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
31 while (( $# > 0 )); do
32 for i in ${1}/*${suffix}; do
33 [[ -f $i ]] && echo ${i##*/}
40 for d in "${args[@]}"; do
41 if [[ -f "$d/$f" ]]; then
49 # source our config dir
50 for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
54 [[ $dracut_rescue_image != "yes" ]] && exit 0
56 if [[ ! -f $INITRDFILE ]]; then
57 dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
61 if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
62 cp "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
66 new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"