sysdeploy/syslinux-menu.inc
2021-03-02 15:52:44 +01:00

55 lines
1.3 KiB
Bash

#!/bin/bash
. syslinux.inc
. drive.inc
function update_syslinux_menu()
{
local drive="$1"
declare -A versions
declare -a files
local imagepath='/os/focal-maas'
files=('boot-kernel.', 'boot-initrd.')
mount_efi "$drive"
find_newest "$drive"
if [ -n "$newest" ]; then
echo "DEFAULT cloud-init-$newest" >> "$mnt"/items.cfg
fi
partition_list "$drive"
for part in $partitions; do
version_from_partnum "$drive" "$part"
versions["$version"]=1
for f in "${files[@]}"; do
if [ ! -e "$mnt"/"$imagepath"/"$f""$version" ]; then
continue
fi
done
cat >> "$mnt"/items.cfg << _EOL_
LABEL cloud-init-$version
MENU LABEL Ubuntu focal (MAAS $version)
KERNEL $imagepath/boot-kernel.$version
APPEND initrd=$imagepath/boot-initrd.$version root=PARTLABEL="rootfs_$version" ip=dhcp overlayroot=tmpfs:recurse=0 ds=nocloud-net;s=https://box.sysdeploy.org/cloud-init/
_EOL_
done
# find expired
for f in "${files[@]}"; do
for i in "$mnt"/"$imagepath"/"$f"*; do
version="$(basename "$i"|cut -d_ -f2-)"
if [ -z "${versions[$version]}" ]; then
rm -f $i
fi
done
done
umount_efi
}
# vim: set ft=sh: