aboutsummaryrefslogtreecommitdiffstats
path: root/element-desktop/umount-element
blob: eb9fbddf6464f19e1fdcf49c3ad31944aa4e8179 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/dash

asroot env \
	ELEMENT_DIR="${HOME}/.var/opt/element" \
	ELEMENT_DEV="$(losetup | sed 's/\s\+/ /g' | cut -d ' ' -f 1,6 | \
	              sed -n 's#\(/[^ ]*\) '"$(realpath -- "${HOME}/.var/opt/element/ElementCrypt.img")"'$#\1#p' | sed 1q)" \
	sh -c '
		if mountpoint -q -- "${ELEMENT_DIR}/ElementCrypt.d"; then
			umount -- "${ELEMENT_DIR}/ElementCrypt.d"
		fi
		if test -e /dev/mapper/ElementCrypt; then
			cryptsetup close ElementCrypt
		fi
		if test -n "${ELEMENT_DEV}"; then
			losetup -d -- "${ELEMENT_DEV}"
		fi
	'