stop on parted error

This commit is contained in:
kmpm 2020-04-09 18:17:47 +02:00
parent 4f61a3244a
commit c99b053afb
1 changed files with 7 additions and 1 deletions

View File

@ -160,7 +160,13 @@ trap cleanup ERR EXIT
#Gather info
info "Gathering data"
beforesize=$(ls -lh "$img" | cut -d ' ' -f 5)
parted_output=$(parted -ms "$img" unit B print | tail -n 1)
if ! parted_output=$(parted -ms "$img" unit B print); then
rc=$?
error $LINENO "parted failed with rc $rc"
info "Possibly invalid image. Run 'parted $img unit B print' manually to investigate"
exit -6
fi
parted_output=$(echo "$parted_output" | tail -n 1)
partnum=$(echo "$parted_output" | cut -d ':' -f 1)
partstart=$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B')
loopback=$(losetup -f --show -o "$partstart" "$img")