diff --git a/vault-install.sh b/vault-install.sh index 86c2415..ae67ecc 100755 --- a/vault-install.sh +++ b/vault-install.sh @@ -103,12 +103,12 @@ cat $VAULT_ROOT/config.hcl # get the version of vault reqeusted or the most current version of open source set_vault_version () { if [[ -z $REQUESTED_VERSION ]]; then - VERSION_LINE=`curl https://releases.hashicorp.com/vault/ | awk 'NR==67' | sed 's/+ent//'` - OPEN_SOURCE_VERSION_S1=`echo $VERSION_LINE | sed 's/\+ent//g'` - export OPEN_SOURCE_VERSION_S2=`echo $OPEN_SOURCE_VERSION_S1 | sed 's/\.hsm//g'` - # Hashi added a new extension to the files. remove that as well to get latest version - export OPEN_SOURCE_VERSION_S2=`echo $OPEN_SOURCE_VERSION_S1 | sed 's/\.fips1402//g'` - export VAULT_VERSION=`echo $OPEN_SOURCE_VERSION_S2 | cut -f2 -d_ | cut -f1 -d\<` + VERSION_LINE=`curl https://releases.hashicorp.com/vault/ | grep '+ent' | awk 'NR==67'` + echo "VERSION_LINE=" $VERSION_LINE + # use cut and remove the data to the right of the +ent + export OPEN_SOURCE_VERSION_S2=`echo $VERSION_LINE | cut -f1 -d+` + # use cut and remove the data to the left of the / that is in front of the verison number we want. + export VAULT_VERSION=`echo $OPEN_SOURCE_VERSION_S2 | cut -f3 -d/` else export VAULT_VERSION=$REQUESTED_VERSION fi @@ -122,7 +122,6 @@ download_vault () { # download the current version of vault else export VAULT_ZIP_NAME="vault_"$VAULT_VERSION"_darwin_amd64.zip" fi - if [[ ! -f ~/Downloads/$VAULT_ZIP_NAME ]]; then curl -o ~/Downloads/$VAULT_ZIP_NAME -k "https://releases.hashicorp.com/vault/"$VAULT_VERSION"/"$VAULT_ZIP_NAME fi @@ -159,11 +158,9 @@ install_vault () { # Install vault start_and_init_vault () { # Initilizse and start vault vault server -config=$VAULT_ROOT/config.hcl & - sleep 5 + sleep 5s vault operator init -key-threshold=1 -key-shares=1 2>&1 > $VAULT_ROOT/init.txt - sleep 5 - #FUTURE: have these goto 1Password awk '/^Unseal Key/' $VAULT_ROOT/init.txt | cut -d ' ' -f4 > $VAULT_ROOT/local-unseal-key awk '/^Initial Root Token/' $VAULT_ROOT/init.txt | cut -d ' ' -f4 > $VAULT_ROOT/local-root-token