diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-09-30 01:00:53 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-09-30 01:00:53 -0300 |
commit | 499d041d6b49dd02467b46f0930808bebc3cf104 (patch) | |
tree | 0d6d7d1fbf66693d39429e8295a9d57ef7d18da0 /share | |
parent | e0581224b1cabbedcb9ef527b5db91bc082711e0 (diff) | |
download | hydra-499d041d6b49dd02467b46f0930808bebc3cf104.tar.gz hydra-499d041d6b49dd02467b46f0930808bebc3cf104.tar.bz2 |
Print fingerprints with correct padding
Diffstat (limited to 'share')
-rwxr-xr-x | share/hydractl/puppet-finger | 24 |
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 |