forked from Bitmessage/sysdeploy
feat: allow multiple drives
This commit is contained in:
parent
d93357cadb
commit
e102469a54
56
install.inc
56
install.inc
|
@ -6,8 +6,33 @@
|
|||
function download_version()
|
||||
{
|
||||
local release_version="$1"
|
||||
local drive="$2"
|
||||
local downloads=~/Downloads
|
||||
pushd "$downloads"
|
||||
|
||||
download_and_verify "$release_version" boot-kernel
|
||||
if [ $? -eq 1 ]; then
|
||||
popd
|
||||
exit 1
|
||||
fi
|
||||
download_and_verify "$release_version" boot-initrd
|
||||
if [ $? -eq 1 ]; then
|
||||
popd
|
||||
exit 1
|
||||
fi
|
||||
download_and_verify "$release_version" squashfs
|
||||
if [ $? -eq 1 ]; then
|
||||
popd
|
||||
exit 1
|
||||
fi
|
||||
popd
|
||||
}
|
||||
|
||||
function install_version()
|
||||
{
|
||||
local drive="$2"
|
||||
local target
|
||||
local downloads=~/Downloads
|
||||
|
||||
find_unused "$drive"
|
||||
target="$unused"
|
||||
|
@ -19,41 +44,22 @@ function download_version()
|
|||
exit 1
|
||||
fi
|
||||
|
||||
downloads="$(mktemp -d)"
|
||||
pushd "$downloads"
|
||||
|
||||
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"
|
||||
mkdir -p "$mnt""$imagepath"
|
||||
mv boot-initrd "$mnt""$imagepath"/boot-initrd."$release_version"
|
||||
mv boot-kernel "$mnt""$imagepath"/boot-kernel."$release_version"
|
||||
[ -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"
|
||||
umount_efi
|
||||
|
||||
dev_from_partnum "$drive" "$target"
|
||||
dd if=squashfs of="$partition" bs=1M
|
||||
rename_partition "$drive" "$target" root_"$release_version"
|
||||
rm -f squashfs
|
||||
popd
|
||||
rmdir "$downloads"
|
||||
update_syslinux_menu "$drive"
|
||||
}
|
||||
|
||||
function cleanup_version()
|
||||
|
||||
# vim: set ft=sh:
|
||||
|
|
16
install.sh
16
install.sh
|
@ -3,17 +3,23 @@
|
|||
. install.inc
|
||||
. drive.inc
|
||||
|
||||
drive="$1"
|
||||
declare -a drives
|
||||
|
||||
if [ ! -b "$drive" ]; then
|
||||
echo "Usage install.sh /dev/wherever"
|
||||
drives=("$@")
|
||||
|
||||
if [ ${#drives[@]} -eq 0 ]; then
|
||||
echo "Usage install.sh /dev/drive1 [/dev/drive2 [/dev/drive3 ]]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
setup_drive "$drive"
|
||||
install_syslinux "$drive"
|
||||
get_streams
|
||||
get_latest_maas_id
|
||||
|
||||
for drive in "${drives[@]}"; do
|
||||
setup_drive "$drive"
|
||||
install_syslinux "$drive"
|
||||
download_version "$release_version" "$drive"
|
||||
install_version "$release_version" "$drive"
|
||||
update_syslinux_menu "$drive"
|
||||
done
|
||||
cleanup_temp
|
||||
|
|
|
@ -50,17 +50,35 @@ function file_url()
|
|||
url="$baseurl/$url"
|
||||
}
|
||||
|
||||
function verify_only()
|
||||
{
|
||||
local release_version="$1"
|
||||
local fname="$2"
|
||||
get_checksum "$release_version" "$fname"
|
||||
sha256sum=$(sha256sum "$fname"|cut -d\ -f1)
|
||||
if [ "$sha256sum" == "$checksum" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function download_and_verify()
|
||||
{
|
||||
local release_version="$1"
|
||||
local fname="$2"
|
||||
|
||||
file_url "$release_version" "$fname"
|
||||
get_checksum "$release_version" "$fname"
|
||||
|
||||
if [ -f "$fname" ]; then
|
||||
if verify_only "$release_version" "$fname"; then
|
||||
echo "$fname already downloaded, skipping"
|
||||
return 0
|
||||
fi
|
||||
echo "Deleting $fname"
|
||||
rm -f "$fname"
|
||||
fi
|
||||
wget "$url" -O "$fname"
|
||||
sha256sum=$(sha256sum "$fname"|cut -d\ -f1)
|
||||
if [ "$sha256sum" == "$checksum" ]; then
|
||||
if verify_only "$release_version" "$fname"; then
|
||||
return 0
|
||||
fi
|
||||
echo "Checksum fail"
|
||||
|
|
12
update.sh
12
update.sh
|
@ -2,15 +2,21 @@
|
|||
|
||||
. install.inc
|
||||
|
||||
drive="$1"
|
||||
declare -a drives
|
||||
|
||||
if [ ! -b "$drive" ]; then
|
||||
echo "Usage update.sh /dev/wherever"
|
||||
drives=("$@")
|
||||
|
||||
if [ ${#drives[@]} -eq 0 ]; then
|
||||
echo "Usage install.sh /dev/drive1 [/dev/drive2 [/dev/drive3 ]]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
get_streams
|
||||
get_latest_maas_id
|
||||
|
||||
for drive in "${drives[@]}"; do
|
||||
download_version "$release_version" "$drive"
|
||||
install_version "$release_version" "$drive"
|
||||
update_syslinux_menu "$drive"
|
||||
done
|
||||
cleanup_temp
|
||||
|
|
Loading…
Reference in New Issue
Block a user