Implemented forced image download

This commit is contained in:
Kevin Veen-Birkenbach 2020-04-30 10:15:26 +02:00
parent bbe78fd5a2
commit e53f0dda38
2 changed files with 23 additions and 10 deletions

View File

@ -23,6 +23,7 @@ To pase the configuration to the program use this syntax:
echo "mmcblk1" # | The device echo "mmcblk1" # | The device
echo "3" # | The raspberry pi number echo "3" # | The raspberry pi number
echo "arch" # | The operation system echo "arch" # | The operation system
echo "n" # | Force image download
echo "y" # | Transfer image echo "y" # | Transfer image
echo "n" # ├── Overwrite device before copying echo "n" # ├── Overwrite device before copying
echo "user_password" # | The user password echo "user_password" # | The user password

View File

@ -127,24 +127,36 @@ case "$os" in
;; ;;
esac esac
echo "Download os-image..." echo "Generating os-image..."
download_url="$base_download_url$imagename" download_url="$base_download_url$imagename"
image_path="$image_folder$imagename" image_path="$image_folder$imagename"
if [ ! -f "$image_path" ] echo "Should the image download be forced?(y/n)" && read force_image_download
if [ $force_image_download = "y" ]
then
if [ -f "$image_path" ]
then
echo "Removing image $image_path."
rm $image_path || error "Removing image \"$image_path\" failed."
else
echo "Forcing download wasn't neccessary. File $image_path doesn't exist."
fi
fi
echo "Start Download procedure..."
if [ -f "$image_path" ]
then then
echo "The selected image \"$imagename\" doesn't exist under local path \"$image_path\"." echo "Image exist local. Download skipped."
if [ ! -f "$image_path" ] else
then echo "Image \"$imagename\" doesn't exist under local path \"$image_path\"."
echo "Image \"$imagename\" gets downloaded from \"$download_url\"..." echo "Image \"$imagename\" gets downloaded from \"$download_url\"..."
wget "$download_url" -P "$image_folder" || error "Download failed." wget "$download_url" -P "$image_folder" || error "Download from \"$download_url\" failed."
fi
fi fi
echo "Verifying image..." echo "Verifying image..."
if [[ -v image_checksum ]] if [[ -v image_checksum ]]
then then
echo "$image_checksum $image_path"| md5sum -c -|| error "Verification failed. Delete image via \"rm $image_path\"." echo "$image_checksum $image_path"| md5sum -c -|| error "Verification failed. HINT: Force the download of the image."
else else
warning "Verification is not possible. No checksum is defined." warning "Verification is not possible. No checksum is defined."
fi fi
@ -223,7 +235,7 @@ if [ "$transfer_image" = "y" ]
;; ;;
"moode") "moode")
unzip -p "$image_path" | sudo dd of="$sd_card_path" bs=1M conv=fsync || error "DD to $sd_card_path failed." unzip -p "$image_path" | sudo dd of="$sd_card_path" bs=1M conv=fsync || error "DD $image_path to $sd_card_path failed."
sync sync
;; ;;
"retropie") "retropie")