aboutsummaryrefslogtreecommitdiffstats
path: root/roles/space_server/files/kernel/95-syslinux-menu.install
blob: 183da9e1529abfee89078c4dd850f40f9c4c5194 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

COMMAND="$1"
KERNEL_VERSION="$2"
BOOT_DIR_ABS="$3"
KERNEL_IMAGE="$4"

if [[ -f /etc/machine-id ]]; then
    read MACHINE_ID < /etc/machine-id
fi

if ! [[ $MACHINE_ID ]]; then
    exit 1
fi

BOOT_DIR="/$MACHINE_ID/$KERNEL_VERSION"
BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
MENU="$BOOT_ROOT/loader/${MACHINE_ID}.cfg"

readarray -t ENTRIES < <(ls -1 -t "$BOOT_ROOT/loader/entries/$MACHINE_ID"-*)

{
  i=0
  for entry in "${ENTRIES[@]}"; do
    echo "LABEL $((++i))"
    echo "INCLUDE ${entry#$BOOT_ROOT}"
  done
} > "$MENU" || {
    echo "Could not create aggregated menu '$MENU'." >&2
    exit 1
}

exit 0