aboutsummaryrefslogtreecommitdiffstats
path: root/element-desktop/bash-aliases
blob: fa8afeab8c7e3b885d5db16e7ff04e68f1c2b902 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# -*- shell-script -*-

mount-element () {
	gpg --decrypt ~/.var/opt/element/ElementCrypt.key | \
	asroot env XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}" ELEMENT_DIR=~/.var/opt/element sh -ec '
		device="$(losetup --show -f -P "${ELEMENT_DIR}/ElementCrypt.img")"
		printf "%s\n" "${device}" > "${XDG_RUNTIME_DIR}/ElementCrypt"
		cryptsetup -d - open "${device}" ElementCrypt
		mount /dev/mapper/ElementCrypt "${ELEMENT_DIR}/ElementCrypt.d"
		'
}

umount-element () {
	asroot env XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}" ELEMENT_DIR=~/.var/opt/element sh -c '
		umount "${ELEMENT_DIR}/ElementCrypt.d"
		cryptsetup close ElementCrypt
		losetup -d "$(cat -- "${XDG_RUNTIME_DIR}/ElementCrypt")"
		rm -f -- "${XDG_RUNTIME_DIR}/ElementCrypt"
		'
}