From 1cbc906cab936cebd32d60039334219ba0f077f9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 19 Nov 2021 09:47:14 +0000 Subject: [PATCH] bugfix: gpg/bin -> gnupg/bin, use 'git config' for name and email --- gpg-pubkey/gpg-pubkey.sh | 13 ++++--------- gpg/README.md | 2 +- gpg/install.sh | 24 +++++++++++------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/gpg-pubkey/gpg-pubkey.sh b/gpg-pubkey/gpg-pubkey.sh index 3145f64..cc0a347 100755 --- a/gpg-pubkey/gpg-pubkey.sh +++ b/gpg-pubkey/gpg-pubkey.sh @@ -3,9 +3,8 @@ set -e set -u function __get_git_email() { - grep 'email\s*=.*@' ~/.gitconfig | - tr -d '\t ' | head -n 1 | - cut -d'=' -f2 + git config --global user.email + # grep 'email\s*=.*@' ~/.gitconfig | tr -d '\t ' | head -n 1 | cut -d'=' -f2 } function __get_pubkey_id() { @@ -20,12 +19,8 @@ function _create_gpg_key() { return 1 fi - MY_NAME="$( - grep 'name\s*=' ~/.gitconfig | - head -n 1 | - cut -d'=' -f2 | - sed -e 's/^[\t ]*//' - )" + #grep 'name\s*=' ~/.gitconfig | head -n 1 | cut -d'=' -f2 | sed -e 's/^[\t ]*//' + MY_NAME="$(git config --global user.name)" if [[ -z ${MY_NAME} ]]; then return 1 fi diff --git a/gpg/README.md b/gpg/README.md index fc76f3f..6e7ac35 100644 --- a/gpg/README.md +++ b/gpg/README.md @@ -90,7 +90,7 @@ You need to use `gpg-connect-agent` instead. gpg-agent ProgramArguments - MY_HOME/.local/opt/gpg/bin/gpg-connect-agent + MY_HOME/.local/opt/gnupg/bin/gpg-connect-agent --agent-program MY_HOME/.local/opt/gnupg/bin/gpg-agent --homedir diff --git a/gpg/install.sh b/gpg/install.sh index 1b5254d..8058709 100644 --- a/gpg/install.sh +++ b/gpg/install.sh @@ -35,7 +35,8 @@ function _install_gpg() { ln -s gnupg-"${WEBI_VERSION}" ~/.local/opt/gnupg pathman add ~/.local/opt/gnupg/bin - export PATH="$HOME/.local/opt/gnupg/bin/:$PATH" + export PATH="$HOME/.local/opt/gnupg/bin:$PATH" + export PATH="$HOME/.local/opt/gnupg/bin/pinentry-mac.app/Contents/MacOS:$PATH" # Prep for first use mkdir -p ~/.gnupg/ @@ -56,7 +57,7 @@ function _install_gpg() { gpg-agent ProgramArguments - '"${HOME}"'/.local/opt/gpg/bin/gpg-connect-agent + '"${HOME}"'/.local/opt/gnupg/bin/gpg-connect-agent --agent-program '"${HOME}"'/.local/opt/gnupg/bin/gpg-agent --homedir @@ -78,6 +79,10 @@ function _install_gpg() { ' > ~/Library/LaunchAgents/gpg-agent.plist launchctl load -w ~/Library/LaunchAgents/gpg-agent.plist sleep 3 + ~/.local/opt/gnupg/bin/gpg-connect-agent \ + --agent-program ~/.local/opt/gnupg/bin/gpg-agent \ + --homedir ~/.gnupg/ \ + /bye # (maybe) Create first key if ! gpg --list-secret-keys | grep -q sec; then @@ -90,21 +95,14 @@ function _create_gpg_key() { return 0 fi - MY_NAME="$( - grep 'name\s*=' ~/.gitconfig | - head -n 1 | - cut -d'=' -f2 | - sed -e 's/^[\t ]*//' - )" + #grep 'name\s*=' ~/.gitconfig | head -n 1 | cut -d'=' -f2 | sed -e 's/^[\t ]*//' + MY_NAME="$(git config --global user.name)" if [[ -z ${MY_NAME} ]]; then return 0 fi - MY_EMAIL="$( - grep 'email\s*=.*@' ~/.gitconfig | - tr -d '\t ' | head -n 1 | - cut -d'=' -f2 - )" + # grep 'email\s*=.*@' ~/.gitconfig | tr -d '\t ' | head -n 1 | cut -d'=' -f2 + MY_EMAIL="$(git config --global user.email)" if [[ -z ${MY_EMAIL} ]]; then return 0 fi -- 2.25.1