Improve gpg-key

Signed-off-by: main <magic_rb@redalder.org>
This commit is contained in:
main 2022-01-26 20:38:46 +01:00
parent 5a72bdc630
commit c7f252f1f0
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E
2 changed files with 8 additions and 5 deletions

View file

@ -5,7 +5,7 @@ final: prev:
name = "gpg-key";
file = ./gpg-key;
substitutes = with prev; {
inherit cryptsetup busybox findutils;
inherit cryptsetup busybox findutils gnupg sudo;
};
};

View file

@ -1,6 +1,6 @@
# -*- mode: shell-script; -*-
export PATH=@findutils@/bin:@busybox@/bin:@cryptsetup@/bin
export PATH=@findutils@/bin:@busybox@/bin:@cryptsetup@/bin:@gnupg@/bin:@sudo@/bin
command="$1"
@ -13,14 +13,17 @@ fi
set -e
case "$command" in
"open")
cryptsetup open /dev/disk/by-label/secret secret
cryptsetup open /dev/disk/by-label/addhe addhe
mkdir -p /mnt/key
mount /dev/mapper/secret /mnt/key
mount /dev/mapper/addhe /mnt/key
sudo -u $SUDO_USER gpg-agent --daemon
;;
"close")
sudo -u $SUDO_USER pkill gpg-agent
umount /mnt/key
cryptsetup close secret
cryptsetup close addhe
rm -r /mnt/key
if [ -n "$(find /mnt -maxdepth 0 -empty)" ]