Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vault-install.sh #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions vault-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down