diff options
-rwxr-xr-x | squashfu | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -119,8 +119,9 @@ unmount_union () { # Returns: return code from umount info "Unmounting union" umount "$UNION_MOUNT" 2>/dev/null + local ret=$? sleep .5 - return $? + return $ret } unmount_squash () { @@ -230,7 +231,8 @@ action_remove_bin () { [[ $UID != 0 ]] && die "Must be root to remove a backup" [[ ! -w "$BINVENTORY" ]] && die "Unable to write to ${BINVENTORY}" - if grep "^$1:" $BINVENTORY && [[ -d "$BINS_DIR/$1" ]]; then + + if grep -q "^$1:" $BINVENTORY && [[ -d "$BINS_DIR/$1" ]]; then if [[ -z $2 ]]; then echo "Are you SURE you want to remove this bin?" local timestamp=$(sed -n "/^$1:/s/^[0-9]*:\([0-9]*\)/\1/p" "$BINVENTORY") @@ -239,15 +241,16 @@ action_remove_bin () { "Date Created:" "$(date --rfc-3339=seconds --date="@$timestamp")" \ "Size:" "$(du -sh "$BINS_DIR/$1" 2>/dev/null | awk '{print $1}')" - echo -ne "\033[1;33m::\033[0m" + echo -ne "\033[1;33m::\033[0m " read -N1 -p "Confirm deletion (y/N) " reply echo - [[ ! "$reply" =~ [Yy] ]] && die "Delete operation aborted" + [[ ! "$reply" = [Yy] ]] && die "Delete operation aborted" fi + mountpoint -q "$UNION_MOUNT" && { unmount_union || die "Failed to unmount union"; } info "Deleting bin $1" sed -i "/^$1:[0-9]*/d" "$BINVENTORY" - rm -rf $BINS_DIR/$1 + rm -rf "$BINS_DIR/$1" else die "Bin $1 not found." fi |