Permalink
Browse files

Better Handling of Open Stuff on Breakdown

Asks to close it, etc.
  • Loading branch information...
1 parent b1d202e commit f755b323d79fe1efeea144bdba0add222816da0c @psycotica0 committed Aug 24, 2011
Showing with 21 additions and 9 deletions.
  1. +21 −9 breakdown_mirror
View
@@ -3,13 +3,25 @@
CACHE_LOCATION="/mnt/cache"
UNION_LOCATION="/mnt/union"
+processes="$(lsof -t "$UNION_LOCATION")"
+
+if [ -n "$processes" ]; then
+ echo "Some processes are still using the mirror, kill anyway?"
+ read answer
+ if [ "$answer" = "y" -o "$answer" = "yes" ]; then
+ echo "$processes" | xargs kill
+ else
+ exit
+ fi
+fi
+
# This is inelegant, but I don't care
-umount "$UNION_LOCATION"/tmp
-umount "$UNION_LOCATION"/proc
-umount "$UNION_LOCATION"/sys
-umount "$UNION_LOCATION"/dev/shm
-umount "$UNION_LOCATION"/dev/pts
-umount "$UNION_LOCATION"/dev
-umount "$UNION_LOCATION"/
-
-umount "$CACHE_LOCATION"
+umount -l "$UNION_LOCATION"/tmp
+umount -l "$UNION_LOCATION"/proc
+umount -l "$UNION_LOCATION"/sys
+umount -l "$UNION_LOCATION"/dev/shm
+umount -l "$UNION_LOCATION"/dev/pts
+umount -l "$UNION_LOCATION"/dev
+umount -l "$UNION_LOCATION"/
+
+umount -l "$CACHE_LOCATION"

0 comments on commit f755b32

Please sign in to comment.