zsh:funcs:crypt-*mount: Create mountpoint symlink

This commit is contained in:
2022-01-29 23:42:07 +01:00
parent c2c0d4fc04
commit 546b37681f

View File

@@ -266,6 +266,12 @@ crypt-mount() {
| awk '{ print $2; }' | awk '{ print $2; }'
)" )"
[[ -d $mount_point ]] && cd "$mount_point" [[ -d $mount_point ]] && cd "$mount_point"
# create link in $HOME/mounts
[[ ! -e "$HOME/mounts/${mount_point:t}" ]] \
|| { echo "~/mounts/${mount_point:t} exists" >&2; return 1; }
mkdir -p ~/mounts/
ln -s "$mount_point" ~/mounts/
} }
crypt-umount() { crypt-umount() {
@@ -276,6 +282,7 @@ crypt-umount() {
sync sync
local name=crypt_"${1##*/}" local name=crypt_"${1##*/}"
if if
mount | grep -q /dev/mapper/"$name" \ mount | grep -q /dev/mapper/"$name" \
&& ! udisksctl unmount -b /dev/mapper/"$name" && ! udisksctl unmount -b /dev/mapper/"$name"
@@ -288,6 +295,14 @@ crypt-umount() {
return 1 return 1
fi fi
udisksctl power-off -b "$1" udisksctl power-off -b "$1"
local mount_point="$(
findmnt -lo SOURCE,TARGET \
| grep -F /dev/mapper/"$name" \
| awk '{ print $2; }'
)"
rm ~/mounts/"$name" && rmdir --ignore-fail-on-non-empty ~/mounts/ \
|| echo "~/mounts/$name did not exist"
} }
if (( $+commands[trash] )); then if (( $+commands[trash] )); then