diff options
author | ache <ache@ache.one> | 2018-01-15 01:34:29 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2018-01-15 01:34:29 +0100 |
commit | 60203948cfc5a343dec3c3766209d4dafce0805e (patch) | |
tree | cad773aab75987ae3e8232997e9753a367fa0dec /cumount.sh | |
parent | Init autoMMS.py (diff) |
Init crypted mount scripts
Diffstat (limited to 'cumount.sh')
-rwxr-xr-x | cumount.sh | 32 |
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 + + + + + |