fix script itself

This commit is contained in:
Philip Henning 2024-01-11 22:38:01 +01:00
parent 240e01257d
commit c2e5c2295d
3 changed files with 12 additions and 8 deletions

View file

@ -11,8 +11,18 @@ set -euf -o pipefail
# age encryption / decryption helpers
# based on https://git.sr.ht/~digital/secretFiles
#
# For macOS coreutils and gnu-getopt are required to
# run this script.
# brew install coreutils gnu-getopt
#
#---------------------------------------------------
#TMPPATH="/dev/shm"
TMPPATH="/tmp"
[[ -d "/opt/homebrew/opt/coreutils/libexec/gnubin" ]] && export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:${PATH}"
[[ -d "/opt/homebrew/opt/gnu-getopt/bin" ]] && export PATH="/opt/homebrew/opt/gnu-getopt/bin:${PATH}"
# get recipients for age file to encrypt with
get-recipients-list() {
local target="${1}"
@ -75,7 +85,7 @@ edit-file() {
local working_directory="${2:-$(pwd)}"
local secret_path="${working_directory}/${1}"
local tmp_path="$(mktemp -p /dev/shm)"
local tmp_path="$(mktemp -p ${TMPPATH})"
local recipients_list=$(get-recipients-list "${secret_path}")
local identity="${MASTERKEY_FILE:-$([[ -f "$(realpath "${working_directory}/secrets/hostkeys/masterkey.privkey")" ]] && echo -n "$(realpath "${working_directory}/secrets/hostkeys/masterkey.privkey")" || echo -n "/dev/stdin")}"
@ -120,7 +130,7 @@ reencrypt-all() {
local working_directory="${2:-$(pwd)}"
local identity="${1:-/dev/stdin}"
local identity_file="$(mktemp -u -p /dev/shm)"
local identity_file="$(mktemp -u -p ${TMPPATH})"
# make the identity file reuseable, in case it actually is /dev/stdin
umask 177