diff options
-rwxr-xr-x | tools/daisy-img-modify.sh | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/daisy-img-modify.sh b/tools/daisy-img-modify.sh index 60b60d26..8e025168 100755 --- a/tools/daisy-img-modify.sh +++ b/tools/daisy-img-modify.sh @@ -135,6 +135,16 @@ install_utils() fi } +# Eliminate exceptions +eliminate() +{ + if [ -b /dev/mapper/$loopdevice ]; then + umount /dev/mapper/$loopdevice || true + dmsetup remove $loopdevice || true + fi + return 0 +} + # resize image resize() { install_utils @@ -149,7 +159,7 @@ resize() { fdisk -l /dev/${loopdevice:0:5} || true growpart /dev/${loopdevice:0:5} 1 dmsetup clear $loopdevice - kpartx -dv $raw_imgfile + kpartx -dv $raw_imgfile || eliminate } # mount image @@ -193,7 +203,7 @@ cleanup() { mount | grep $mountdir/proc && umount $mountdir/proc mount | grep $mountdir && umount $mountdir if [ -f $raw_imgfile ]; then - kpartx -dv $raw_imgfile || true + kpartx -dv $raw_imgfile || eliminate fi rm -f $raw_imgfile rm -rf $mountdir |