From ffbf818c97278006db5933520a5f9dc7d6a348ee Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 2 Mar 2021 17:00:17 +0100 Subject: [PATCH] fix: typos, checksum, ordering --- install.inc | 17 ++++++++++++++++- maas-images.inc | 3 ++- syslinux-menu.inc | 3 +++ syslinux.inc | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/install.inc b/install.inc index 3a49c92..a515fad 100644 --- a/install.inc +++ b/install.inc @@ -22,9 +22,24 @@ function download_version() downloads="$(mktemp -d)" pushd "$downloads" - download_and_verify "$release_version" boot-initrd download_and_verify "$release_version" boot-kernel + if [ $? -eq 1 ]; then + popd + rm -rf "$downloads" + exit 1 + fi + download_and_verify "$release_version" boot-initrd + if [ $? -eq 1 ]; then + popd + rm -rf "$downloads" + exit 1 + fi download_and_verify "$release_version" squashfs + if [ $? -eq 1 ]; then + popd + rm -rf "$downloads" + exit 1 + fi mount_efi "$drive" mv boot-init "$mnt"/boot-initrd."$release_version" diff --git a/maas-images.inc b/maas-images.inc index b38bb7a..5f08ab1 100644 --- a/maas-images.inc +++ b/maas-images.inc @@ -54,10 +54,11 @@ function download_and_verify() get_checksum "$release_version" "$fname" wget "$url" -O "$fname" - sha256sum=$(sha256sum "$fname") + sha256sum=$(sha256sum "$fname"|cut -d\ -f1) if [ "$sha256sum" == "$checksum" ]; then return 0 fi + echo "Checksum fail" rm -f "$fname" return 1 } diff --git a/syslinux-menu.inc b/syslinux-menu.inc index e7a6ed4..bc8f1e5 100644 --- a/syslinux-menu.inc +++ b/syslinux-menu.inc @@ -23,6 +23,9 @@ function update_syslinux_menu() partition_list "$drive" for part in $partitions; do version_from_partnum "$drive" "$part" + if [ -z "$version" ]; then + continue + fi versions["$version"]=1 for f in "${files[@]}"; do if [ ! -e "$mnt"/"$imagepath"/"$f""$version" ]; then diff --git a/syslinux.inc b/syslinux.inc index c3cd46e..cb18cea 100644 --- a/syslinux.inc +++ b/syslinux.inc @@ -36,7 +36,7 @@ function mount_efi() function umount_efi() { umount "$mnt" - flush + sync rmdir "$mnt" }