From db62822a42c77272c1c768d1c22367a1dae6bcfc Mon Sep 17 00:00:00 2001 From: framp Date: Sun, 19 Aug 2018 22:05:28 +0200 Subject: [PATCH] Removed some checks --- pishrink.sh | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/pishrink.sh b/pishrink.sh index 1294aad..3a4481a 100755 --- a/pishrink.sh +++ b/pishrink.sh @@ -107,29 +107,11 @@ trap cleanup ERR EXIT #Gather info info "Gatherin data" beforesize=$(ls -lh "$img" | cut -d ' ' -f 5) -logVariables $LINENO beforesize -if ! parted_output=$(parted -ms "$img" unit B print); then - rc=$? - error $LINENO "parted failed with rc $rc" - exit -6 -fi -parted_output=$(tail -n 1 <<< $parted_output) -logVariables $LINENO parted_output - +parted_output=$(parted -ms "$img" unit B print | tail -n 1) partnum=$(echo "$parted_output" | cut -d ':' -f 1) partstart=$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B') -logVariables $LINENO partnum partstart - -info "Mounting image" -if ! loopback=$(losetup -f --show -o $partstart "$img"); then - rc=$? - error $LINENO "losetup failed with rc $rc" - exit -7 -fi -if ! tune2fs_output=$(tune2fs -l "$loopback"); then - error $LINENO "tunefs failed" - exit -8 -fi +loopback=$(losetup -f --show -o $partstart "$img") +tune2fs_output=$(tune2fs -l "$loopback") currentsize=$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2) blocksize=$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2) @@ -285,6 +267,7 @@ if ! truncate -s $endresult "$img"; then rc=$? error $LINENO "trunate failed with rc $rc" exit -16 +fi aftersize=$(ls -lh "$img" | cut -d ' ' -f 5) logVariables $LINENO aftersize