diff options
author | Mattias Andrée <maandree@kth.se> | 2021-06-26 20:04:40 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-06-26 20:04:40 +0200 |
commit | d0c754055ddfcc56feae567b16b9044baada1386 (patch) | |
tree | 8d8e21d00daaa3e512c5e21d6e0c805ba212b409 /gnupg | |
parent | Add the wrappers c, dmenu, mplayer, st, and aur (diff) | |
download | dotfiles-d0c754055ddfcc56feae567b16b9044baada1386.tar.gz dotfiles-d0c754055ddfcc56feae567b16b9044baada1386.tar.bz2 dotfiles-d0c754055ddfcc56feae567b16b9044baada1386.tar.xz |
Add e, ge, decrypt, encrypt, and encrypt-nosign
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | gnupg/Makefile | 8 | ||||
-rwxr-xr-x | gnupg/decrypt | 13 | ||||
-rwxr-xr-x | gnupg/encrypt | 10 | ||||
-rwxr-xr-x | gnupg/encrypt-nosign | 10 |
4 files changed, 41 insertions, 0 deletions
diff --git a/gnupg/Makefile b/gnupg/Makefile index 6583b2d..76f83e9 100644 --- a/gnupg/Makefile +++ b/gnupg/Makefile @@ -13,10 +13,18 @@ install: mkdir -p -- ~/.config/profile.d test ! -d ~/.config/profile.d/gnupg ln -sf -- ~/.dotfiles/gnupg/user-profile ~/.config/profile.d/gnupg + $(CHECK_INSTALLED) dash + mkdir -p -- ~/.local/bin + ln -sf -- ~/.dotfiles/gnupg/decrypt ~/.local/bin/ + ln -sf -- ~/.dotfiles/gnupg/encrypt ~/.local/bin/ + ln -sf -- ~/.dotfiles/gnupg/encrypt-nosign ~/.local/bin/ uninstall: -unlink -- ~/.config/profile.d/gnupg -rmdir -- ~/.config/profile.d -unlink -- ~/.var/lib/gnupg + -unlink -- ~/.local/bin/decrypt + -unlink -- ~/.local/bin/encrypt + -unlink -- ~/.local/bin/encrypt-nosign .PHONY: install uninstall diff --git a/gnupg/decrypt b/gnupg/decrypt new file mode 100755 index 0000000..57db255 --- /dev/null +++ b/gnupg/decrypt @@ -0,0 +1,13 @@ +#!/bin/dash +if test -z "${GPG_KEY}"; then + printf '\033[1;31m%s\033[0m\n' 'You must export GPG_KEY with you GPG key' >&2 + exit 1 +else + for file in "$@"; do + if test "${file}" = "${file%*.crypt}"; then + gpg --decrypt < "${file}" > "${file%*.crypt}" + else + gpg --decrypt < "${file}" > "${file}.decrypted" + fi + done +fi diff --git a/gnupg/encrypt b/gnupg/encrypt new file mode 100755 index 0000000..e91190f --- /dev/null +++ b/gnupg/encrypt @@ -0,0 +1,10 @@ +#!/bin/dash +if test -z "${GPG_KEY}"; then + printf '\033[1;34m%s\033[0m\n' 'You must export GPG_KEY with you GPG key' >&2 + exit 1 +else + for file in "$@"; do + gpg --encrypt --sign -r "${GPG_KEY}" -u "${GPG_KEY}" < "${file}" > "${file}.crypt" + done + printf '\033[1;34m%s\033[0m\n' '-- Do not forget to shred. --' >&2 +fi diff --git a/gnupg/encrypt-nosign b/gnupg/encrypt-nosign new file mode 100755 index 0000000..c4446b1 --- /dev/null +++ b/gnupg/encrypt-nosign @@ -0,0 +1,10 @@ +#!/bin/dash +if test -z "${GPG_KEY}"; then + printf '\033[1;31m%s\033[0m\n' 'You must export GPG_KEY with you GPG key' >&2 + exec 1 +else + for file in "$@"; do + gpg --encrypt -r "${GPG_KEY}" < "${file}" > "${file}.crypt" + done + printf '\033[1;34m%s\033[0m\n' '-- Do not forget to shred. --' >&2 +fi |