Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions installer/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ load_cluster_state_env() {
# fi
# export ADMIN_EMAIL=$(openssl x509 -in ${SAVE_DIR}/fullchain-${AWS_ACCOUNT}-${CLUSTER_NAME}.pem -noout -email)
# fi

restore_env_from_s3
}

clone_repo() {
Expand Down
22 changes: 22 additions & 0 deletions pod-configs/utils/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ upload_savedir() {
fi
}

restore_env_from_s3() {
if [ ! -f ${HOME}/.env ] && [ -n "${BUCKET_NAME:-}" ] && [ -n "${AWS_REGION:-}" ] && [ -n "${SAVE_DIR_S3:-}" ]; then
if check_s3_savedir_file .env 2>/dev/null; then
echo "Info: Restoring .env file from S3..."
download_savedir_file .env
if [ -f ${SAVE_DIR}/.env ]; then
cp ${SAVE_DIR}/.env ${HOME}/.env
chmod 600 ${HOME}/.env
echo "Info: .env file restored from S3."
export $(cat ${HOME}/.env | xargs)
fi
fi
fi
}

backup_env_to_s3() {
if [[ -f ~/.env ]]; then
cp ~/.env ${SAVE_DIR}/.env
upload_savedir_file .env
fi
}

remove_s3_data() {
files=$(all_data_files_v2)
for file in $files; do
Expand Down
9 changes: 8 additions & 1 deletion pod-configs/utils/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,6 @@ EOF

popd


jq -n ". += {\"gitea_argo_user\":${gitea_argo_user}}" | \
jq ". += {\"gitea_argo_token\":${gitea_argo_token}}" | \
jq ". += {\"gitea_co_user\":${gitea_co_user}}" | \
Expand Down Expand Up @@ -1358,6 +1357,8 @@ action_orch_loadbalancer() {
echo "ARGOCD_TG_ARN=${argocd_tg_arn}" >> ~/.env
fi
popd

backup_env_to_s3
fi

rm -rf $dir
Expand Down Expand Up @@ -1665,6 +1666,7 @@ install() {
if ! check_s3_savedir_empty && ! [[ -f ${values_changed} ]]; then
download_savedir
echo "Info: Pulled S3 ${SAVE_DIR}."
restore_env_from_s3
fi

if [[ ! -f ${SAVE_DIR}/${VARIABLE_TFVAR} ]]; then
Expand Down Expand Up @@ -1736,6 +1738,7 @@ uninstall() {
if ! check_s3_savedir_empty && ! [[ -f ${values_changed} ]]; then
download_savedir
echo "Info: Pulled S3 ${SAVE_DIR}."
restore_env_from_s3
else
echo "Warning: Failed to download data files from S3. Make sure the value specified for the --customer-state-prefix parameter is correct. Type \"yes\" to continue, others to quit: "; read s

Expand Down Expand Up @@ -1809,6 +1812,7 @@ pull-savedir() {
if check_local_savedir_empty && ! check_s3_savedir_empty; then
download_savedir
echo "Info: files have been pulled in the ${SAVE_DIR} directory."
restore_env_from_s3
else
echo "Error: Some files have existed. No file is pulled. If you really want to pull, remove the files related to ${ENV_NAME} from the ${SAVE_DIR} directory and try again."
exit 1
Expand Down Expand Up @@ -1939,6 +1943,7 @@ config() {
if ! check_s3_savedir_empty && ! [[ -f ${values_changed} ]]; then
download_savedir
echo "Info: Pulled S3 ${SAVE_DIR}."
restore_env_from_s3
fi

set_values "config"
Expand Down Expand Up @@ -2010,6 +2015,7 @@ upgrade() {
echo "Info: Checking deployed version..."

download_savedir
restore_env_from_s3
load_values
check_running_sshuttle
refresh_sshuttle
Expand Down Expand Up @@ -2069,6 +2075,7 @@ update-cluster-setting() {
if ! check_s3_savedir_empty; then
download_savedir
echo "Info: Pulled S3 ${SAVE_DIR}."
restore_env_from_s3
fi

local profile_file="$SAVE_DIR/$PROFILE_TFVAR"
Expand Down
Loading