bugfix: gpg/bin -> gnupg/bin, use 'git config' for name and email
authorAJ ONeal <aj@therootcompany.com>
Fri, 19 Nov 2021 09:47:14 +0000 (09:47 +0000)
committerAJ ONeal <aj@therootcompany.com>
Fri, 19 Nov 2021 09:47:14 +0000 (09:47 +0000)
gpg-pubkey/gpg-pubkey.sh
gpg/README.md
gpg/install.sh

index 3145f6420347b135cd15838f94651d3db96ff2ba..cc0a347a34dd58d35d70be631c3a1aad39047bc0 100755 (executable)
@@ -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
index fc76f3fb1043aa02feaf9379cf896d42c19ea7d3..6e7ac357359f6c04bfc578dba99b38b6f93f10a1 100644 (file)
@@ -90,7 +90,7 @@ You need to use `gpg-connect-agent` instead.
        <string>gpg-agent</string>
        <key>ProgramArguments</key>
        <array>
-               <string>MY_HOME/.local/opt/gpg/bin/gpg-connect-agent</string>
+               <string>MY_HOME/.local/opt/gnupg/bin/gpg-connect-agent</string>
                <string>--agent-program</string>
                <string>MY_HOME/.local/opt/gnupg/bin/gpg-agent</string>
                <string>--homedir</string>
index 1b5254d8bd121de6feec6f28bb5d10726a233256..8058709c22584655f77349b3883bc7e309ed2e5c 100644 (file)
@@ -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() {
        <string>gpg-agent</string>
        <key>ProgramArguments</key>
        <array>
-               <string>'"${HOME}"'/.local/opt/gpg/bin/gpg-connect-agent</string>
+               <string>'"${HOME}"'/.local/opt/gnupg/bin/gpg-connect-agent</string>
                <string>--agent-program</string>
                <string>'"${HOME}"'/.local/opt/gnupg/bin/gpg-agent</string>
                <string>--homedir</string>
@@ -78,6 +79,10 @@ function _install_gpg() {
 </plist>' > ~/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