2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
10 if [[ -f /etc/machine-id ]]; then
11 read MACHINE_ID < /etc/machine-id
14 if ! [[ $MACHINE_ID ]]; then
18 BOOT_DIR="/$MACHINE_ID/$KERNEL_VERSION"
19 LOADER_ENTRY="/boot/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
21 if [[ $COMMAND == remove ]]; then
22 exec rm -f "$LOADER_ENTRY"
25 if ! [[ $COMMAND == add ]]; then
29 if ! [[ $KERNEL_IMAGE ]]; then
33 if [[ -f /etc/os-release ]]; then
37 if ! [[ $PRETTY_NAME ]]; then
38 PRETTY_NAME="Linux $KERNEL_VERSION"
41 if [[ -f /etc/kernel/cmdline ]]; then
42 readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
45 if ! [[ ${BOOT_OPTIONS[*]} ]]; then
46 readarray -t BOOT_OPTIONS < /proc/cmdline
49 if ! [[ $BOOT_OPTIONS ]]; then
50 echo "Could not determine the kernel command line parameters." >&2
51 echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2
55 cp --preserve "$KERNEL_IMAGE" "$BOOT_DIR_ABS/linux" || {
56 echo "Could not copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'." >&2
60 mkdir -p "${LOADER_ENTRY%/*}" || {
61 echo "Could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2
66 echo "title $PRETTY_NAME"
67 echo "version $KERNEL_VERSION"
68 echo "machine-id $MACHINE_ID"
69 echo "options ${BOOT_OPTIONS[*]}"
70 echo "linux $BOOT_DIR/linux"
71 [[ -f $BOOT_DIR_ABS/initrd ]] && \
72 echo "initrd $BOOT_DIR/initrd"
73 } > "$LOADER_ENTRY" || {
74 echo "Could not create loader entry '$LOADER_ENTRY'." >&2