uccpass: regenerate .gpg-id when reloading keys
[zanchey/uccpass.git] / uccpass
diff --git a/uccpass b/uccpass
index 62c42e3..e4c48c7 100755 (executable)
--- a/uccpass
+++ b/uccpass
 init () {
     # Check for pass subcommand
     if ! type pass >/dev/null; then
-        echo "$0: can't find the pass(1) command, is it installed correctly?"
+        echo "uccpass: can't find the pass(1) command, is it installed correctly?"
     fi
     if ! type gpg2 >/dev/null; then
-        echo "$0: can't find gpg2(1), is it installed correctly?"
+        echo "uccpass: can't find gpg2(1), is it installed correctly?"
     fi
 
     UCCPASS_ROOT="/home/wheel/bin/uccpass"
@@ -37,10 +37,14 @@ init () {
     export PASSWORD_STORE_DIR="$UCCPASS_ROOT/store"
     export PASSWORD_STORE_UMASK=007
 
+    USER=`whoami`
     export GIT_AUTHOR_EMAIL="[email protected]"
     export GIT_AUTHOR_NAME="`getent passwd $USER | cut -d: -f5`"
 
     export GPG_TTY=`tty`
+    export PASSWORD_STORE_GPG_OPTS="--trust-model always"
+
+    export PATH=$UCCPASS_ROOT/pass/bin:$PATH
 
     if [ -n "$UCCPASS_DEBUG" ]; then set -x; fi
 }
@@ -73,10 +77,11 @@ add_to_shell () {
 
 refresh_keys () {
     gpg2 --quiet --import $UCCPASS_KEYRING
+    gpg2 --with-colons $UCCPASS_KEYRING | grep '^pub' | cut -d: -f5 > $PASSWORD_STORE_DIR/.gpg-id
 }
 
 new_user_setup () {
-    echo " >  Setting you up for $0"
+    echo " >  Setting you up for uccpass"
 
     # Set up an agent
     echo -n " >> Checking for running GPG agent... "
@@ -85,7 +90,7 @@ new_user_setup () {
         echo "not found."
         USER_SHELL=`basename $SHELL`
         if echo $USER_SHELL | egrep -q 'zsh|bash|fish'; then
-            echo " [!] $0 can install an password caching agent into your shell initialisation files."
+            echo " [!] uccpass can install an password caching agent into your shell initialisation files."
             echo -n " [?] Do you want to do so? [Y/n] " 
             read install_agent
             case $install_agent in
@@ -122,15 +127,6 @@ new_user_setup () {
     # Get the key fingerprint
     KEY_FINGERPRINT=`gpg --list-secret-keys --with-fingerprint --with-colons $GIT_AUTHOR_EMAIL | grep '^fpr' | head -n 1 | cut -d: -f 10`
 
-    # Add to .gpg-id
-    echo -n " >> Adding your key to the access list... "
-    if grep -qF "$KEY_FINGERPRINT" $PASSWORD_STORE_DIR/.gpg-id; then
-        echo "already present!"
-    else
-        echo "$KEY_FINGERPRINT" >> $PASSWORD_STORE_DIR/.gpg-id
-        echo "ok."
-    fi
-
     # Add to key list
     # XXX: is it worth submitting these to an online keyserver?
     echo -n " >> Adding your key to the shared keyring... "
@@ -141,8 +137,8 @@ new_user_setup () {
     fi
 
     # Done!
-    echo " > $0 setup complete."
-    echo " [!] Ask someone with existing access to the password store to run \`$0 reload\`."
+    echo " > uccpass setup complete."
+    echo " [!] Ask someone with existing access to the password store to run \`uccpass reload\`."
 }
 
 init
@@ -161,7 +157,7 @@ case "$1" in
         ;;
     help|--help)
         command pass $@
-        echo "$0 also supports the following commands:"
+        echo "uccpass also supports the following commands:"
         echo "setup: generate a new key and insert it into the password store"
         echo "reload: re-encrypt the password store"
         ;;

UCC git Repository :: git.ucc.asn.au