aboutsummaryrefslogtreecommitdiff
path: root/cumount.sh
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-01-15 01:34:29 +0100
committerache <ache@ache.one>2018-01-15 01:34:29 +0100
commit60203948cfc5a343dec3c3766209d4dafce0805e (patch)
treecad773aab75987ae3e8232997e9753a367fa0dec /cumount.sh
parentInit autoMMS.py (diff)
Init crypted mount scripts
Diffstat (limited to 'cumount.sh')
-rwxr-xr-xcumount.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/cumount.sh b/cumount.sh
new file mode 100755
index 0000000..3a45c06
--- /dev/null
+++ b/cumount.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+if [ -z "$1" ] ; then
+ echo 'Need a name to umount'
+ exit 1
+fi
+
+name="${1}"
+
+mountpoint=$(lsblk -lo NAME,MOUNTPOINT | grep "${1}" | tr -s ' ' | cut -d' ' -f 2)
+
+if [ -z "${mountpoint}" ] ; then
+ echo "${name} not found"
+ exit 1
+fi
+
+if sudo umount "${mountpoint}" ; then
+ if sudo cryptsetup luksClose "${name}" ; then
+ echo 'Finish'
+ else
+ echo "Error : ${name} can't be closed"
+ exit 2
+ fi
+else
+ echo "Error : ${mountpoint} can't be umounted"
+ exit 3
+fi
+
+
+
+
+