2021-03-02 12:12:10 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
. syslinux.inc
|
|
|
|
. drive.inc
|
2021-03-02 18:56:20 +01:00
|
|
|
imagepath='/os/focal-maas'
|
2021-03-02 12:12:10 +01:00
|
|
|
|
|
|
|
function update_syslinux_menu()
|
|
|
|
{
|
|
|
|
local drive="$1"
|
|
|
|
declare -A versions
|
|
|
|
declare -a files
|
|
|
|
|
2021-03-02 23:15:02 +01:00
|
|
|
files=('boot-kernel.' 'boot-initrd.')
|
2021-03-02 12:12:10 +01:00
|
|
|
|
|
|
|
mount_efi "$drive"
|
|
|
|
|
|
|
|
find_newest "$drive"
|
|
|
|
|
2021-03-02 21:20:17 +01:00
|
|
|
> "$mnt"/syslinux/items.cfg
|
2021-03-02 12:12:10 +01:00
|
|
|
if [ -n "$newest" ]; then
|
2021-03-02 21:20:17 +01:00
|
|
|
version_from_partnum "$drive" "$newest"
|
|
|
|
echo "DEFAULT cloud-init-$version" >> "$mnt"/syslinux/items.cfg
|
2021-03-02 12:12:10 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
partition_list "$drive"
|
|
|
|
for part in $partitions; do
|
|
|
|
version_from_partnum "$drive" "$part"
|
2021-03-02 17:00:17 +01:00
|
|
|
if [ -z "$version" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2021-03-02 12:12:10 +01:00
|
|
|
versions["$version"]=1
|
2021-03-02 21:20:17 +01:00
|
|
|
missing=""
|
2021-03-02 15:52:44 +01:00
|
|
|
for f in "${files[@]}"; do
|
2021-03-02 23:54:35 +01:00
|
|
|
if [ ! -e "$mnt""$imagepath"/"$f""$version" ]; then
|
2021-03-02 21:20:17 +01:00
|
|
|
missing="1"
|
2021-03-02 12:12:10 +01:00
|
|
|
fi
|
|
|
|
done
|
2021-03-02 21:20:17 +01:00
|
|
|
if [ -n "$missing" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
cat >> "$mnt"/syslinux/items.cfg << _EOL_
|
2021-03-02 12:12:10 +01:00
|
|
|
|
|
|
|
LABEL cloud-init-$version
|
|
|
|
MENU LABEL Ubuntu focal (MAAS $version)
|
|
|
|
KERNEL $imagepath/boot-kernel.$version
|
2021-03-03 00:29:56 +01:00
|
|
|
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/
|
2021-03-02 15:52:44 +01:00
|
|
|
_EOL_
|
2021-03-02 12:12:10 +01:00
|
|
|
done
|
|
|
|
|
2021-03-02 14:39:19 +01:00
|
|
|
# find expired
|
2021-03-02 15:52:44 +01:00
|
|
|
for f in "${files[@]}"; do
|
2021-03-02 23:54:35 +01:00
|
|
|
for i in "$mnt""$imagepath"/"$f"*; do
|
|
|
|
version="$(basename "$i"|cut -d. -f2-)"
|
2021-03-02 14:39:19 +01:00
|
|
|
if [ -z "${versions[$version]}" ]; then
|
|
|
|
rm -f $i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
umount_efi
|
2021-03-02 12:12:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# vim: set ft=sh:
|