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