forked from Bitmessage/sysdeploy
72 lines
1.4 KiB
Bash
72 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
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
|
|
return 1
|
|
fi
|
|
release_version=$(jq -r '.products[]|select(.version=="'"$OS_VERSION"'" and .arch=="amd64" and .kflavor=="generic" and .subarch=="ga-'"$OS_VERSION"'")|.versions|keys|max' \
|
|
"$streams")
|
|
}
|
|
|
|
function get_checksum()
|
|
{
|
|
local release_version="$1"
|
|
local filename="$2"
|
|
checksum=$(jq -r '.products[]|select(.version=="'"$OS_VERSION"'" and .arch=="amd64" and .kflavor=="generic" and .subarch=="ga-'"$OS_VERSION"'").versions."'"$release_version"'".items."'"$filename"'".sha256' \
|
|
"$streams")
|
|
}
|
|
|
|
function download_and_verify()
|
|
{
|
|
local url="$1"
|
|
local checksum="$2"
|
|
local fname="$3"
|
|
|
|
wget "$url" -O "$fname"
|
|
sha256sum=$(sha256sum "$fname")
|
|
if [ "$sha256sum" == "$checksum" ]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
function cleanup_temp()
|
|
{
|
|
if [ -f "$streams" ]; then
|
|
rm -f "$streams"
|
|
fi
|
|
}
|
|
|
|
function download_files()
|
|
{
|
|
download kernel
|
|
download initrd
|
|
download squashfs
|
|
|
|
dd if=squashfs of="$partition" bs=1M
|
|
|
|
create_options_file
|
|
update_default
|
|
delete_oldest_if_needed
|
|
update_onerror_second_youngest
|
|
}
|
|
|
|
# vim: set ft=sh:
|