From 751b2246c7a32a01b9ae5b23abd948a1e48066c6 Mon Sep 17 00:00:00 2001 From: substantialcattle5 Date: Sun, 14 Jul 2024 18:51:55 +0530 Subject: [PATCH] fix: shell script update --- functions/dccheck.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/functions/dccheck.sh b/functions/dccheck.sh index c99c8df..0b53028 100755 --- a/functions/dccheck.sh +++ b/functions/dccheck.sh @@ -21,7 +21,8 @@ calculate_splits() { local imagename="$2" # Fetch the size from rbd info - size=10 + size=$(rbd snap ls "$1"/"$2" | grep -oP '\d+\s+[\w.]+\s+\K\d+\s+\w+' | awk '{print $1}') + if [[ -z "$size" ]]; then echo "Error: Could not determine size of the image. Exiting." exit 1 @@ -49,10 +50,12 @@ export_and_checksums() { local imagename="$3" local splitsize=$(calculate_splits "$poolname" "$imagename") + echo "Running ${operation} and checksums for ${poolname}/${imagename}..." + echo "Splitting the Image based on ${splitsize}G....." # Export RBD image, split into chunks, and hash each chunk - snapshot_file="./GD.iso" - split -b ${splitsize}G "${snapshot_file}" --filter='sha256sum' | ( + rbd ${operation} "${poolname}/${imagename}" - | split -b ${splitsize}G - --filter='sha256sum' | ( while read -r hash filename; do + echo "$hash" chunk_hashes+=("$hash") done ) @@ -69,8 +72,8 @@ poolname="$2" imagename="$3" # Check for rbd installation +check_rbd_command # # Run the export and calculate checksums - export_and_checksums "$operation" "$poolname" "$imagename" calculate_combined_checksum