aboutsummaryrefslogtreecommitdiffstats
path: root/vault.sh
diff options
context:
space:
mode:
Diffstat (limited to 'vault.sh')
-rwxr-xr-xvault.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/vault.sh b/vault.sh
index bac110e..6bf443a 100755
--- a/vault.sh
+++ b/vault.sh
@@ -5,4 +5,12 @@ set -ex
password_bin=$(command -v pass || command -v gopass)
password_name="${2:-infrastructure/ansible/root}"
-"${password_bin}" show "${password_name}" | head -n 1
+set +x
+
+if [ "$(logname)" != "$(whoami)" ]; then
+ password_string="$(su "$(logname)" -c "${password_bin} show ${password_name}")"
+else
+ password_string="$("${password_bin}" show "${password_name}")"
+fi
+
+echo "${password_string}" | head -n 1
remember that computers suck.