chore(e2e): Add boundary to path (#4901)

This adds the boundary application to the path on the respective ec2 instances.
This commit is contained in:
Michael Li authored and GitHub committed 2024-06-24 14:01:58 -04:00
1 parent e2872275dc
commit 8b45b1c515
4 files changed
+157

No files matched your search

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -e
fail() {
echo "$1" 1>&2
exit 1
}
[[ -z "$BOUNDARY_INSTALL_DIR" ]] && fail "BOUNDARY_INSTALL_DIR env variable has not been set"
# Determine the profile file we should write to. We only want to affect login shells and bash will
# only read one of these in ordered of precendence.
determineProfileFile() {
if [ -f "$HOME/.bash_profile" ]; then
printf "%s/.bash_profile\n" "$HOME"
return 0
fi
if [ -f "$HOME/.bash_login" ]; then
printf "%s/.bash_login\n" "$HOME"
return 0
fi
printf "%s/.profile\n" "$HOME"
}
appendVaultProfileInformation() {
tee -a "$1" <<< "export PATH=$PATH:$BOUNDARY_INSTALL_DIR"
}
main() {
local profile_file
if ! profile_file=$(determineProfileFile); then
fail "failed to determine login shell profile file location"
fi
# If vault_cluster is used more than once, eg: autopilot or replication, this module can
# be called more than once. Short ciruit here if our profile is already set up.
if grep VAULT_ADDR < "$profile_file"; then
exit 0
fi
if ! appendVaultProfileInformation "$profile_file"; then
fail "failed to write vault configuration to login shell profile"
fi
exit 0
}
main