aboutsummaryrefslogtreecommitdiffstats
path: root/bash/aliases-Zenith
blob: 419de1df212cf3eee95e48c9b19b1ae51ec1c9b6 (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-crypt () {
	asroot env XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}" CRYPT_DIR=~/Crypt sh -ec '
		device="$(losetup --show -f -P /media/Secondary/.crypt/crypt.img)"
		printf "%s\n" "${device}" > "${XDG_RUNTIME_DIR}/CryptCrypt"
		gpg --decrypt /media/Secondary/.crypt/crypt.key | cryptsetup -d - open "${device}" CryptCrypt
		mkdir -p "${CRYPT_DIR}"
		mount /dev/mapper/CryptCrypt "${CRYPT_DIR}"
		'
}

umount-crypt () {
	asroot env XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}" CRYPT_DIR=~/Crypt sh -c '
		umount "${CRYPT_DIR}"
		rmdir "${CRYPT_DIR}"
		cryptsetup close CryptCrypt
		losetup --detach "$(cat -- "${XDG_RUNTIME_DIR}/CryptCrypt")"
		'
}