sysdeploy/install.inc

70 lines
1.5 KiB
PHP
Raw Normal View History

2021-03-02 14:45:59 +00:00
#!/bin/bash
. maas-images.inc
. syslinux-menu.inc
function download_version()
{
local release_version="$1"
local drive="$2"
2021-03-04 14:36:22 +00:00
local downloads=~/Downloads
mkdir -p "$downloads"
2021-03-02 14:45:59 +00:00
pushd "$downloads"
download_and_verify "$release_version" boot-kernel
2021-03-02 16:00:17 +00:00
if [ $? -eq 1 ]; then
popd
exit 1
fi
download_and_verify "$release_version" boot-initrd
if [ $? -eq 1 ]; then
popd
exit 1
fi
2021-03-02 14:45:59 +00:00
download_and_verify "$release_version" squashfs
2021-03-02 16:00:17 +00:00
if [ $? -eq 1 ]; then
popd
2021-03-04 14:36:22 +00:00
exit 1
fi
popd
}
function install_version()
{
local drive="$2"
local target
local downloads=~/Downloads
mkdir -p "$downloads"
2021-03-04 14:36:22 +00:00
find_unused "$drive"
target="$unused"
if [ -z "$unused" ]; then
find_oldest "$drive"
target="$unused"
fi
if [ -z "$target" ]; then
2021-03-02 16:00:17 +00:00
exit 1
fi
2021-03-02 14:45:59 +00:00
2021-03-04 14:36:22 +00:00
pushd "$downloads"
2021-03-02 14:45:59 +00:00
mount_efi "$drive"
2021-03-02 19:00:26 +00:00
mkdir -p "$mnt""$imagepath"
2021-03-04 14:36:22 +00:00
[ -f "$mnt""$imagepath"/boot-initrd."$release_version" ] || \
cp boot-initrd "$mnt""$imagepath"/boot-initrd."$release_version"
[ -f "$mnt""$imagepath"/boot-kernel."$release_version" ] || \
cp boot-kernel "$mnt""$imagepath"/boot-kernel."$release_version"
2021-03-02 14:45:59 +00:00
umount_efi
dev_from_partnum "$drive" "$target"
dd if=squashfs of="$partition" bs=1M
rename_partition "$drive" "$target" root_"$release_version"
popd
update_syslinux_menu "$drive"
}
2021-03-05 21:04:09 +00:00
#function cleanup_version()
2021-03-04 14:36:22 +00:00
2021-03-02 14:45:59 +00:00
# vim: set ft=sh: