64 lines
1.5 KiB
Bash
64 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
. syslinux.inc
|
|
. drive.inc
|
|
imagepath='/os/focal-maas'
|
|
|
|
function update_syslinux_menu()
|
|
{
|
|
local drive="$1"
|
|
declare -A versions
|
|
declare -a files
|
|
|
|
files=('boot-kernel.' 'boot-initrd.')
|
|
|
|
mount_efi "$drive"
|
|
|
|
find_newest "$drive"
|
|
|
|
> "$mnt"/syslinux/items.cfg
|
|
if [ -n "$newest" ]; then
|
|
version_from_partnum "$drive" "$newest"
|
|
echo "DEFAULT cloud-init-$version" >> "$mnt"/syslinux/items.cfg
|
|
fi
|
|
|
|
partition_list "$drive"
|
|
for part in $partitions; do
|
|
version_from_partnum "$drive" "$part"
|
|
if [ -z "$version" ]; then
|
|
continue
|
|
fi
|
|
versions["$version"]=1
|
|
missing=""
|
|
for f in "${files[@]}"; do
|
|
if [ ! -e "$mnt""$imagepath"/"$f""$version" ]; then
|
|
missing="1"
|
|
fi
|
|
done
|
|
if [ -n "$missing" ]; then
|
|
continue
|
|
fi
|
|
cat >> "$mnt"/syslinux/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="root_$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:
|