dotfiles/nix/overlays/gpg-key/gpg-key
Magic_RB 11fc09120b
Switch old halfFlake system to regular overlays
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2021-04-09 00:35:36 +02:00

38 lines
579 B
Bash

# -*- mode: shell-script; -*-
export PATH=@findutils@/bin:@busybox@/bin:@cryptsetup@/bin
command="$1"
if [ "$(id -u)" != "0" ]
then
echo "You must this script as root."
exit 1
fi
set -e
case "$command" in
"open")
cryptsetup open /dev/disk/by-label/secret secret
mkdir -p /mnt/key
mount /dev/mapper/secret /mnt/key
;;
"close")
umount /mnt/key
cryptsetup close secret
rm -r /mnt/key
if [ -n "$(find /mnt -maxdepth 0 -empty)" ]
then
rm -r /mnt
fi
;;
*)
cat <<EOF
open - open key
close - close key
EOF
;;
esac