aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2010-06-12 21:19:08 -0400
committerDave Reisner <d@falconindy.com>2010-06-12 21:19:08 -0400
commit70d66ecdb668e3947fb5e8b8f2f68f17c571e848 (patch)
treec41dc2b95ccb85e3e9bcf911a7654676cdfa813c
parent8ccb3b8213ebb8c082fd87cfd6d8ce3f38c7d5b8 (diff)
downloadsquashfu-70d66ecdb668e3947fb5e8b8f2f68f17c571e848.tar.gz
deletion: ensure that the union is unmounted before deleting. fail hard if we can't unmount. quiet down the initial grep call
-rwxr-xr-xsquashfu13
1 files changed, 8 insertions, 5 deletions
diff --git a/squashfu b/squashfu
index 7c666ed..0fa1d1e 100755
--- a/squashfu
+++ b/squashfu
@@ -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