aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl/puppet-finger
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl/puppet-finger')
-rwxr-xr-xshare/hydractl/puppet-finger24
1 files changed, 17 insertions, 7 deletions
diff --git a/share/hydractl/puppet-finger b/share/hydractl/puppet-finger
index 2bd29c1..cb84335 100755
--- a/share/hydractl/puppet-finger
+++ b/share/hydractl/puppet-finger
@@ -16,7 +16,19 @@ function puppet_openssl {
return
fi
- openssl x509 -text -noout -fingerprint -in $1 | grep "^SHA1 Fingerprint="
+ openssl x509 -text -noout -fingerprint -in $1 | grep "^SHA1 Fingerprint=" | \
+ sed -e 's/^SHA1 Fingerprint=//'
+}
+
+# Print a fingerprint with correct padding.
+function print_fingerprint {
+ if [ -z "$2" ]; then
+ return
+ fi
+
+ len="`echo $1 | wc -c`"
+ offset="$((85 - $len))"
+ printf "$1: %${offset}s\n" "$2"
}
# Master:
@@ -28,12 +40,12 @@ if [ -d "/var/lib/puppetmaster/ssl" ]; then
if [ -d "/var/lib/puppetmaster/ssl/ca/signed" ]; then
for file in `ls /var/lib/puppetmaster/ssl/ca/signed`; do
fp="`puppet_openssl /var/lib/puppetmaster/ssl/ca/signed/$file`"
- echo "`basename $file .pem`: $fp"
+ print_fingerprint `basename $file .pem` $fp
done
fi
if [ -f "/var/lib/puppetmaster/ssl/certs/ca.pem" ]; then
- echo "ca: `puppet_openssl /var/lib/puppetmaster/ssl/certs/ca.pem`"
+ print_fingerprint ca `puppet_openssl /var/lib/puppetmaster/ssl/certs/ca.pem`
fi
fi
@@ -44,8 +56,6 @@ fi
#
if [ -d "/var/lib/puppet/ssl" ]; then
fqdn="`facter fqdn`"
- fp="`puppet_openssl /var/lib/puppet/ssl/certs/$fqdn.pem`"
- echo "$fqdn: $fp"
-
- echo "ca: `puppet_openssl /var/lib/puppet/ssl/certs/ca.pem`"
+ print_fingerprint $fqdn `puppet_openssl /var/lib/puppet/ssl/certs/$fqdn.pem`
+ print_fingerprint ca `puppet_openssl /var/lib/puppet/ssl/certs/ca.pem`
fi