aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/pumount
diff options
context:
space:
mode:
authorVG <vg@devys.org>2017-05-11 10:01:40 +0200
committerVG <vg@devys.org>2017-05-11 10:01:40 +0200
commitdc8d497a298165ec954a5ff550cd97c79dde1a8a (patch)
treed53a673d2a8f4b52d806a1bf365fe6245e38b33e /scripts/pumount
parent0cbddfab73b55bdfad07991663a56c84fea026e3 (diff)
downloadscripts-dc8d497a298165ec954a5ff550cd97c79dde1a8a.tar.gz
scripts-dc8d497a298165ec954a5ff550cd97c79dde1a8a.tar.bz2
scripts-dc8d497a298165ec954a5ff550cd97c79dde1a8a.zip
add more scripts
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