Created
August 31, 2015 14:29
-
-
Save naunga/8ad873dbf760e69884e2 to your computer and use it in GitHub Desktop.
Output the URL for a Vault server based on the configuration file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
proto="https://" | |
while read line; do | |
if [[ $line =~ listener ]]; then | |
listener_section=1 | |
elif [[ $listener_section == 1 ]] && [[ $line != "}" ]]; then | |
key=$( echo $line | cut -d'=' -f 1 | sed 's/\s*//g' | sed 's/\"//g') | |
val=$( echo $line | cut -d'=' -f 2 | sed 's/\s*//g' | sed 's/\"//g') | |
case "$key" in | |
address ) | |
addr=$val | |
;; | |
tls_disable ) | |
if [[ $val == 1 ]]; then | |
proto="http://" | |
fi | |
esac | |
fi | |
done < "$1" | |
echo "$proto$addr" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment