From c2e5c2295dce5e2d48ed839647cb987bd74293e1 Mon Sep 17 00:00:00 2001 From: shokinn Date: Thu, 11 Jan 2024 22:38:01 +0100 Subject: [PATCH] fix script itself --- dotfiles/bin/secretfiles | 14 ++++++++++++-- dotfiles/zshenv | 3 --- dotfiles/zshrc | 3 --- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dotfiles/bin/secretfiles b/dotfiles/bin/secretfiles index 8496a20..f625511 100755 --- a/dotfiles/bin/secretfiles +++ b/dotfiles/bin/secretfiles @@ -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 diff --git a/dotfiles/zshenv b/dotfiles/zshenv index 7251b70..fe3c7ce 100644 --- a/dotfiles/zshenv +++ b/dotfiles/zshenv @@ -20,9 +20,6 @@ export ANSIBLE_NOCOWS=1 # Include $(go env GOPATH) to PATH [[ $(command -v go) ]] && [[ -d "$(go env GOPATH)/bin" ]] && export PATH="$(go env GOPATH)/bin:${PATH}" -# Include /opt/homebrew/opt/gnu-getopt/bin to PATH -[[ -d "/opt/homebrew/opt/gnu-getopt/bin" ]] && export PATH="/opt/homebrew/opt/gnu-getopt/bin:${PATH}" - {%@@ if profile == 'AINCRAD-wsl' or profile == 'AINCRAD' or profile == 'YOETUNHEIMR-wsl' or profile == 'yoetunheimr' or profile == 'ymir' @@%} # Connect to windows ssh pageant # https://github.com/BlackReloaded/wsl2-ssh-pageant diff --git a/dotfiles/zshrc b/dotfiles/zshrc index 59f94df..b56361d 100644 --- a/dotfiles/zshrc +++ b/dotfiles/zshrc @@ -199,9 +199,6 @@ export PATH="${brew_path}:${PATH}" # Functions (or more complex aliases) source {{@@ env['HOME'] @@}}/.commonfunc -# Include /opt/homebrew/opt/gnu-getopt/bin to PATH -[[ -d "/opt/homebrew/opt/gnu-getopt/bin" ]] && export PATH="/opt/homebrew/opt/gnu-getopt/bin:${PATH}" - {%@@ if profile == 'ymir' @@%} autoload -Uz compinit zstyle ':completion:*' menu select