mirror of
				https://github.com/kevinveenbirkenbach/linux-image-manager.git
				synced 2025-11-03 17:08:03 +00:00 
			
		
		
		
	Implemented count for blocks to overwrite; https://chatgpt.com/share/ac2b59af-c0f0-486f-89fe-0301d4915837
This commit is contained in:
		@@ -95,15 +95,28 @@ set_device_path(){
 | 
			
		||||
  info "Optimal blocksize set to: $OPTIMAL_BLOCKSIZE" || error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
overwritte_device_with_zeros(){
 | 
			
		||||
  question "Should $device_path be overwritten with zeros before copying?(y/N)" && read -r copy_zeros_to_device
 | 
			
		||||
  if [ "$copy_zeros_to_device" = "y" ]
 | 
			
		||||
    then
 | 
			
		||||
      info "Overwritting..." &&
 | 
			
		||||
      dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" status=progress || error "Overwritting $device_path failed."
 | 
			
		||||
overwrite_device() {
 | 
			
		||||
  question "Should $device_path be overwritten with zeros before copying? (y/N/block count)" && read -r copy_zeros_to_device
 | 
			
		||||
  case "$copy_zeros_to_device" in
 | 
			
		||||
    y)
 | 
			
		||||
      info "Overwriting entire device..." &&
 | 
			
		||||
      dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" status=progress || error "Overwriting $device_path failed."
 | 
			
		||||
      ;;
 | 
			
		||||
    N)
 | 
			
		||||
      info "Skipping Overwriting..."
 | 
			
		||||
      ;;
 | 
			
		||||
    ''|*[!0-9]*)
 | 
			
		||||
      error "Invalid input."
 | 
			
		||||
      ;;
 | 
			
		||||
    *)
 | 
			
		||||
      if [[ "$copy_zeros_to_device" =~ ^[0-9]+$ ]]; then
 | 
			
		||||
        info "Overwriting $copy_zeros_to_device blocks..." &&
 | 
			
		||||
        dd if=/dev/zero of="$device_path" bs="$OPTIMAL_BLOCKSIZE" count="$copy_zeros_to_device" status=progress || error "Overwriting $device_path failed."
 | 
			
		||||
      else
 | 
			
		||||
      info "Skipping Overwritting..."
 | 
			
		||||
        error "Invalid input. Block count must be a number."
 | 
			
		||||
      fi
 | 
			
		||||
      ;;
 | 
			
		||||
  esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
get_packages(){
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ echo "Setups disk encryption"
 | 
			
		||||
 | 
			
		||||
set_device_mount_partition_and_mapper_paths
 | 
			
		||||
 | 
			
		||||
overwritte_device_with_zeros
 | 
			
		||||
overwrite_device
 | 
			
		||||
 | 
			
		||||
info "Creating new GPT partition table..."
 | 
			
		||||
(	echo "g"	# create a new empty GPT partition table
 | 
			
		||||
 
 | 
			
		||||
@@ -263,7 +263,7 @@ if [ "$transfer_image" = "y" ]
 | 
			
		||||
        info "Skipping partition table deletion..."
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    overwritte_device_with_zeros
 | 
			
		||||
    overwrite_device
 | 
			
		||||
 | 
			
		||||
    info "Starting image transfer..."
 | 
			
		||||
    if [ "$distribution" = "arch" ]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user