feat: add and update syslinux
This commit is contained in:
parent
ded9b60bf7
commit
ef7291d9b8
|
@ -83,7 +83,7 @@ function version_from_partnum
|
|||
$6 != "root unused") {
|
||||
print $6
|
||||
}}')"
|
||||
version="$(echo "$version"|cut -d\ -f2)"
|
||||
version="$(echo "$version"|cut -d_ -f2-)"
|
||||
}
|
||||
|
||||
# vim: set ft=sh:
|
||||
|
|
|
@ -3,19 +3,13 @@
|
|||
OS_CODENAME=focal
|
||||
OS_VERSION=20.04
|
||||
|
||||
|
||||
function get_streams()
|
||||
{
|
||||
streams="$(mktemp)"
|
||||
wget -qO "$streams" https://images.maas.io/ephemeral-v3/stable/streams/v1/com.ubuntu.maas:stable:v3:download.json
|
||||
}
|
||||
|
||||
|
||||
function find_oldest()
|
||||
{
|
||||
# find locally
|
||||
return 0
|
||||
}
|
||||
|
||||
function get_latest_maas_id()
|
||||
{
|
||||
if [ ! -f "$streams" ]; then
|
||||
|
@ -33,6 +27,12 @@ function get_checksum()
|
|||
"$streams")
|
||||
}
|
||||
|
||||
function remove_version()
|
||||
{
|
||||
local version="$1"
|
||||
|
||||
}
|
||||
|
||||
function download_and_verify()
|
||||
{
|
||||
local url="$1"
|
||||
|
|
55
syslinux.inc
Normal file
55
syslinux.inc
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
function mount_efi()
|
||||
{
|
||||
local drive="$1"
|
||||
local partition="$drive"1
|
||||
if [ ! -b "$partition" ]; then
|
||||
partition="$drive"p1
|
||||
if [ ! -b "$partition" ]; then
|
||||
echo "Can't find first partition for \"$drive\""
|
||||
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
unset mnt
|
||||
mnt="$(mktemp -d)"
|
||||
if ! mount "$partition" "$mnt"; then
|
||||
mkfs.vfat "$partition"
|
||||
if ! mount "$partition" "$mnt"; then
|
||||
echo "Can't mount \"$partition\""
|
||||
cleanup_mnt
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup_mnt()
|
||||
{
|
||||
umount "$mnt"
|
||||
flush
|
||||
rmdir "$mnt"
|
||||
}
|
||||
|
||||
function install_syslinux()
|
||||
{
|
||||
local drive="$1"
|
||||
|
||||
mount_efi "$drive"
|
||||
|
||||
# legacy
|
||||
cp /usr/lib/syslinux/modules/bios/*.c32 "$mnt"/syslinux/
|
||||
|
||||
# UEFI
|
||||
cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi "$mnt"/EFI/BOOT/BOOTX64.EFI
|
||||
cp /usr/lib/syslinux/modules/efi64/ldlinux.e64 "$mnt"/EFI/BOOT/ldlinux.e64
|
||||
cp /usr/lib/syslinux/modules/efi64/*.c32 "$mnt"/EFI/BOOT/
|
||||
cp syslinux/{mainmenu,syslinux}.cfg "$mnt"/syslinux
|
||||
cp syslinux/syslx64.cfg "$mnt"/EFI/BOOT
|
||||
|
||||
cleanup_mnt
|
||||
syslinux "$partition"
|
||||
}
|
||||
|
||||
# vim: set ft=sh:
|
4
syslinux/mainmenu.cfg
Normal file
4
syslinux/mainmenu.cfg
Normal file
|
@ -0,0 +1,4 @@
|
|||
TIMEOUT 50
|
||||
TOTALTIMEOUT 3000
|
||||
|
||||
INCLUDE /syslinux/items.cfg
|
|
@ -1,8 +1,4 @@
|
|||
MENU TITLE Legacy boot
|
||||
UI vesamenu.c32
|
||||
TIMEOUT 50
|
||||
TOTALTIMEOUT 3000
|
||||
|
||||
DEFAULT cloud-init-latest
|
||||
|
||||
INCLUDE /syslinux/mainmenu.cfg
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
MENU TITLE UEFI boot
|
||||
UI vesamenu.c32
|
||||
TIMEOUT 50
|
||||
TOTALTIMEOUT 3000
|
||||
|
||||
DEFAULT cloud-init-latest
|
||||
|
||||
INCLUDE /syslinux/mainmenu.cfg
|
||||
|
|
44
syslinux_menu.inc
Normal file
44
syslinux_menu.inc
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/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 "$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
|
||||
|
||||
cleanup_mnt
|
||||
}
|
||||
|
||||
# vim: set ft=sh:
|
|
@ -1,7 +1,7 @@
|
|||
BYT;
|
||||
T_E_M_P:17.2GB:file:512:512:gpt::;
|
||||
1:1049kB:1074MB:1073MB::EFI system partition:boot, legacy_boot, esp;
|
||||
2:1075MB:2147MB:1073MB::root 20210228:;
|
||||
2:1075MB:2147MB:1073MB::root_20210228:;
|
||||
3:2149MB:3221MB:1073MB::root unused:;
|
||||
4:3222MB:4295MB:1073MB::root unused:;
|
||||
5:4296MB:17.2GB:12.9GB::Encrypted:;
|
||||
|
|
|
@ -15,7 +15,7 @@ function test_partitioning()
|
|||
sed -i "s|T_E_M_P|$img|g;" tests/data/parted.dat
|
||||
assertEquals "setup_drive" "$(cat tests/data/parted.dat)" "$output"
|
||||
|
||||
rename_partition "$img" 2 "root $test_version"
|
||||
rename_partition "$img" 2 "root_$test_version"
|
||||
output=$(parted -ms "$img" -- print)
|
||||
sed -i "s|T_E_M_P|$img|g;" tests/data/rename.dat
|
||||
assertEquals "rename_partition" "$(cat tests/data/rename.dat)" "$output"
|
||||
|
@ -28,13 +28,13 @@ function test_partitioning()
|
|||
version_from_partnum "$img" 3
|
||||
assertEquals "version_from_partnum unused" "" "$version"
|
||||
|
||||
rename_partition "$img" 3 "root $min_version"
|
||||
rename_partition "$img" 3 "root_$min_version"
|
||||
find_oldest "$img"
|
||||
assertEquals "find_oldest" 3 "$oldest"
|
||||
version_from_partnum "$img" 3
|
||||
assertEquals "version_from partnum 3" "$min_version" "$version"
|
||||
|
||||
rename_partition "$img" 4 "root $max_version"
|
||||
rename_partition "$img" 4 "root_$max_version"
|
||||
find_newest "$img"
|
||||
assertEquals "find_newest" 4 "$newest"
|
||||
version_from_partnum "$img" 4
|
||||
|
|
Loading…
Reference in New Issue
Block a user