aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/pumount
blob: db1ce8b435406ee02d2f7007d2325d02281583fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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