kernel-install: teach bot loader spec entry generator to generate entries with "tries"
This makes two changes: 1. When called for "remove" any drop-ins with "+" suffix are removed too, so that the logic works for entries with boot counting enabled too and we don't lose track of configuration snippets created that way. 2. When called for "add" we optionally generate a "+" suffix, based on the data in /etc/kernel/tries if it exists. This basically means after "echo 5 > /etc/kernel/tries" any installed kernels will automatically set up for 5 boot tries before older kernels will be tried.
This commit is contained in:
parent
8d16ed0785
commit
bf7b6d28c3
|
@ -19,10 +19,11 @@ MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
|
|||
|
||||
BOOT_DIR="/$MACHINE_ID/$KERNEL_VERSION"
|
||||
BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
|
||||
LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
|
||||
|
||||
if [[ $COMMAND == remove ]]; then
|
||||
exec rm -f "$LOADER_ENTRY"
|
||||
rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
|
||||
rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+"*".conf"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [[ $COMMAND == add ]]; then
|
||||
|
@ -63,6 +64,17 @@ if ! [[ ${BOOT_OPTIONS[*]} ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f /etc/kernel/tries ]]; then
|
||||
read -r TRIES </etc/kernel/tries
|
||||
if ! [[ "$TRIES" =~ ^[0-9]+$ ]] ; then
|
||||
echo "/etc/kernel/tries does not contain an integer." >&2
|
||||
exit 1
|
||||
fi
|
||||
LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+$TRIES.conf"
|
||||
else
|
||||
LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
|
||||
fi
|
||||
|
||||
cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS/linux" &&
|
||||
chown root:root "$BOOT_DIR_ABS/linux" &&
|
||||
chmod 0644 "$BOOT_DIR_ABS/linux" || {
|
||||
|
|
Loading…
Reference in New Issue