From 00213d01da907d27d1b66d6c9481f1bd0b48582b Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 26 Jun 2013 12:58:06 +0300 Subject: [PATCH] setup-gummiboot-conf: handle the case of absent default entry When the kernel which corresponds to the current default entry is removed, the script fails. Fix this. Signed-off-by: Artem Bityutskiy --- setup-gummiboot-conf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup-gummiboot-conf b/setup-gummiboot-conf index 81dda83..4af3d56 100755 --- a/setup-gummiboot-conf +++ b/setup-gummiboot-conf @@ -56,8 +56,12 @@ default_entry="$(cat "$conf_file" | sed -n -e 's/[ \t]*default[ \t]\+\(.\+\)[ \t fatal "cannot find the default entry in \"$conf_file\"" [ "$(printf "%s\n" "$default_entry" | wc -l)" -eq "1" ] || \ fatal "more than one default entry in \"$conf_file\"" -[ -f "$entries_dir/$default_entry" ] || \ - fatal "the default gummiboot entry file does not exist: \"$entries_dir/$default_entry\"" + +if ! [ -f "$entries_dir/$default_entry" ]; then + # The default entry does not exist anymore. Pick the entry + # corresponding to the newest kernel then. + default_entry="$(printf "%s" "$entries" | head -n1)" +fi # Use the default entry to prepare the pattern for other entries pattern="$(cat "$entries_dir/$default_entry")" -- 2.7.4