Implemented transfering of manjaro isos

This commit is contained in:
Kevin Veen-Birkenbach 2020-05-18 21:01:18 +02:00
parent e25b75a873
commit f1349be5c0
3 changed files with 34 additions and 23 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
decrypted/ decrypted/
.encrypted/ .encrypted/
*package-lock.json *package-lock.json
log.txt

View File

@ -83,18 +83,22 @@ To pase the configuration to the program use this syntax:
```bash ```bash
( (
echo "$USER" # | The username echo "$USER" # | The username
echo "mmcblk1" # | The device echo "sdX" # | The device
echo "3" # | The raspberry pi number echo "64_bit" # | The architecture type; arm or 64_bit
echo "arch" # | The operation system echo "manjaro" # | The operation system
echo "architect" # | The version
#echo "n" # ├── If arch: Should a encrypted setup be used? (y/n) #echo "n" # ├── If arch: Should a encrypted setup be used? (y/n)
echo "n" # | Force image download echo "n" # | Should the image download be forced?(y/n)
echo "n" # | Transfer image echo "y" # | Should the image be transfered to $device_path?(y/n)
#echo "n" # ├── If image transfer yes Overwrite device before copying? (y/n) echo "n" # ├── Overwrite device before copying? (y/n)
echo "test12345" # | The user password echo "n" # | Should the ssh-key be copied to the image?(y/N)
echo "test12345" # | The root password #echo "test12345" # ├── The user password_1
echo "example-host" # | The hostname #echo "test12345" # ├── The user password_2
echo "y" # | Setup Wifi on target system echo "n" # | Should the ssh-key be copied to the image?(y/N)
)| sudo bash ./scripts/image/setup.sh echo "n" # |Should the hostname be changed?(y/N)
#echo "example-host" # | The hostname
#echo "y" # | Setup Wifi on target system - Not implemented yet
)| sudo bash ./scripts/image/setup.sh | tee log.txt
``` ```
## License ## License

View File

@ -82,7 +82,7 @@ case "$architecture" in
;; ;;
"64_bit") "64_bit")
case "$os" in case "$os" in
"arm") "manjaro")
echo "1) architect" echo "1) architect"
;; ;;
*) *)
@ -122,7 +122,7 @@ case "$os" in
case "$version" in case "$version" in
"architect") "architect")
image_checksum="6b1c2fce12f244c1e32212767a9d3af2cf8263b2" image_checksum="6b1c2fce12f244c1e32212767a9d3af2cf8263b2"
base_download_url="https://osdn.net/frs/redir.php?m=dotsrc&f=%2Fstorage%2Fg%2Fm%2Fma%2Fmanjaro%2Farchitect%2F20.0%2Fmanjaro-architect-20.0-200426-linux56.iso"; base_download_url="https://osdn.net/frs/redir.php?m=dotsrc&f=%2Fstorage%2Fg%2Fm%2Fma%2Fmanjaro%2Farchitect%2F20.0%2F";
imagename="manjaro-architect-20.0-200426-linux56.iso" imagename="manjaro-architect-20.0-200426-linux56.iso"
;; ;;
*) *)
@ -171,7 +171,7 @@ if [ "$force_image_download" = "y" ]
then then
if [ -f "$image_path" ] if [ -f "$image_path" ]
then then
info "Removing image $image_path." info "Removing image $image_path." &&
rm "$image_path" || error "Removing image \"$image_path\" failed." rm "$image_path" || error "Removing image \"$image_path\" failed."
else else
info "Forcing download wasn't neccessary. File $image_path doesn't exist." info "Forcing download wasn't neccessary. File $image_path doesn't exist."
@ -185,7 +185,7 @@ if [ -f "$image_path" ]
else else
info "Image \"$imagename\" doesn't exist under local path \"$image_path\"." info "Image \"$imagename\" doesn't exist under local path \"$image_path\"."
info "Image \"$imagename\" gets downloaded from \"$download_url\"..." info "Image \"$imagename\" gets downloaded from \"$download_url\"..."
wget "$download_url" -P "$image_folder" || error "Download from \"$download_url\" failed." wget "$download_url" -O "$image_path" || error "Download from \"$download_url\" failed."
fi fi
info "Verifying image..." info "Verifying image..."
@ -202,6 +202,10 @@ make_mount_folders
set_partition_paths set_partition_paths
# @see https://www.heise.de/ct/hotline/Optimale-Blockgroesse-fuer-dd-2056768.html
optimal_blocksize=$(expr 64 \* "$(sudo cat /sys/block/$device/queue/physical_block_size)") &&
info "Calculated optimal blocksize of $optimal_blocksize""Byte for \"dd\" operations."
question "Should the image be transfered to $device_path?(y/n)" && read -r transfer_image question "Should the image be transfered to $device_path?(y/n)" && read -r transfer_image
if [ "$transfer_image" = "y" ] if [ "$transfer_image" = "y" ]
then then
@ -210,7 +214,7 @@ if [ "$transfer_image" = "y" ]
if [ "$copy_zeros_to_device" = "y" ] if [ "$copy_zeros_to_device" = "y" ]
then then
info "Overwritting..." && info "Overwritting..." &&
dd if=/dev/zero of="$device_path" bs=1M || error "Overwritting $device_path failed." dd if=/dev/zero of="$device_path" bs="$optimal_blocksize" || error "Overwritting $device_path failed."
else else
info "Skipping Overwritting..." info "Skipping Overwritting..."
fi fi
@ -252,25 +256,27 @@ if [ "$transfer_image" = "y" ]
info "Boot files will be transfered to device..." && info "Boot files will be transfered to device..." &&
mv -v "$root_mount_path/boot/"* "$boot_mount_path" || mv -v "$root_mount_path/boot/"* "$boot_mount_path" ||
error error
elif [${image_path: -4} = ".zip" ] elif [ "${image_path: -4}" = ".zip" ]
then then
unzip -p "$image_path" | sudo dd of="$device_path" bs=1M conv=fsync || error "DD $image_path to $device_path failed." && info "Transfering .zip file..." &&
unzip -p "$image_path" | sudo dd of="$device_path" bs="$optimal_blocksize" conv=fsync || error "DD $image_path to $device_path failed." &&
sync || sync ||
error error
elif [${image_path: -3} = ".gz" ] elif [ "${image_path: -3}" = ".gz" ]
then then
gunzip -c "$image_path" | sudo dd of="$device_path" bs=1M conv=fsync && info "Transfering .gz file..." &&
gunzip -c "$image_path" | sudo dd of="$device_path" bs="$optimal_blocksize" conv=fsync &&
sync || sync ||
error error
elif [${image_path: -4} = ".iso" ] elif [ "${image_path: -4}" = ".iso" ]
then then
sudo dd of="$device_path" bs=1M conv=fsync && info "Transfering .iso file..." &&
sudo dd if="$image_path" of="$device_path" bs="$optimal_blocksize" conv=fsync &&
sync || sync ||
error error
else else
error "Image transfer for operation system \"$os\" is not supported yet!"; error "Image transfer for operation system \"$os\" is not supported yet!";
fi fi
esac
else else
info "Skipping image transfer..." info "Skipping image transfer..."
fi fi