aboutsummaryrefslogblamecommitdiffstats
path: root/element-desktop/bash-aliases
blob: 5eada3e8996a5a8c5281ae3f0a44b2c98fcf0f3e (plain) (tree)
1
2
3
4
5
6
7
8


                      
                                                         


                                                                                           
                                                             










                                                                                          
# -*- shell-script -*-

mount-element () {
	gpg --decrypt ~/.var/element/ElementCrypt.key | \
	asroot env XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}" ELEMENT_DIR=~/.var/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/element sh -c '
		umount "${ELEMENT_DIR}/ElementCrypt.d"
		cryptsetup close ElementCrypt
		losetup --detach "$(cat -- "${XDG_RUNTIME_DIR}/ElementCrypt")"
		'
}