aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/pumount
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pumount')
-rwxr-xr-xscripts/pumount44
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/pumount b/scripts/pumount
new file mode 100755
index 0000000..db1ce8b
--- /dev/null
+++ b/scripts/pumount
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+set -e
+
+dash_found=
+for arg in "$@"; do
+ if [ -z "${arg##-*}" ]; then
+ dash_found=true
+ break
+ fi
+done
+
+if [ "$#" -gt 0 ]; then
+ if [ -n "$dash_found" ]; then
+ exec /usr/bin/pumount "$@"
+ fi
+ for arg in "$@"; do
+ /usr/bin/pumount "$arg"
+ done
+ exit 0
+fi
+
+cd /media/
+
+mps=(*)
+
+if [ ${#mps[@]} -eq 0 ]; then
+ echo "Nothing to be done."
+ exit 0
+fi
+
+if [ ${#mps[@]} -eq 1 ]; then
+ if [ "${mps[0]}" == "*" ]; then
+ echo "Nothing to be done."
+ exit 0
+ fi
+ echo "unmounting /media/${mps[0]}"
+ exec /usr/bin/pumount "/media/${mps[0]}"
+fi
+
+select mp in ${mps[*]}; do
+ echo "unmounting /media/$mp"
+ exec /usr/bin/pumount "/media/$mp"
+done