summaryrefslogtreecommitdiff
path: root/src/kernel-install/90-loaderentry.install
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-22 17:35:53 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-19 22:34:50 +0200
commitbf7b6d28c3252cb97df228df185ad0be7609b31b (patch)
tree7d6eed2883e8eda4a5c09b1e91afbbf3ed1a032f /src/kernel-install/90-loaderentry.install
parent8d16ed0785769bf35903970808678f7973fee273 (diff)
downloadsystemd-bf7b6d28c3252cb97df228df185ad0be7609b31b.tar.gz
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.
Diffstat (limited to 'src/kernel-install/90-loaderentry.install')
-rw-r--r--src/kernel-install/90-loaderentry.install16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
index a271cdb8a0..39ec8a69c6 100644
--- a/src/kernel-install/90-loaderentry.install
+++ b/src/kernel-install/90-loaderentry.install
@@ -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" || {