From af589f3d6582d164ae2896b66d8a9941ca006bf1 Mon Sep 17 00:00:00 2001 From: Wundy <108152418+trv-dwunder2@users.noreply.github.com> Date: Wed, 19 Apr 2023 10:29:50 -0400 Subject: [PATCH 1/2] Update vault-install.sh Fix issue with new hashi structure with new extension type --- vault-install.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vault-install.sh b/vault-install.sh index 86c2415..e844610 100755 --- a/vault-install.sh +++ b/vault-install.sh @@ -106,8 +106,10 @@ set_vault_version () { 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 + # They added a new extentsion export OPEN_SOURCE_VERSION_S2=`echo $OPEN_SOURCE_VERSION_S1 | sed 's/\.fips1402//g'` + + echo "OPEN_SOURCE_VERSION_S2=" $OPEN_SOURCE_VERSION_S2 export VAULT_VERSION=`echo $OPEN_SOURCE_VERSION_S2 | cut -f2 -d_ | cut -f1 -d\<` else export VAULT_VERSION=$REQUESTED_VERSION @@ -122,7 +124,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 +160,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 From 98d868c0120a88ef63706d61c21aa79277391bda Mon Sep 17 00:00:00 2001 From: Wundy <108152418+trv-dwunder2@users.noreply.github.com> Date: Mon, 24 Apr 2023 08:46:52 -0400 Subject: [PATCH 2/2] Update vault-install.sh Better way to get the current version --- vault-install.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/vault-install.sh b/vault-install.sh index e844610..ae67ecc 100755 --- a/vault-install.sh +++ b/vault-install.sh @@ -103,14 +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'` - # They added a new extentsion - export OPEN_SOURCE_VERSION_S2=`echo $OPEN_SOURCE_VERSION_S1 | sed 's/\.fips1402//g'` - - echo "OPEN_SOURCE_VERSION_S2=" $OPEN_SOURCE_VERSION_S2 - 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