aboutsummaryrefslogblamecommitdiffstats
path: root/bash/aliases-Zenith
blob: 419de1df212cf3eee95e48c9b19b1ae51ec1c9b6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                      






                                                                                                             


                 





                                                                                 
 
# -*- 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")"
		'
}