diff --git a/ansible/archival-snapshots/resources/set_env.sh b/ansible/archival-snapshots/resources/set_env.sh index d8315fe29..b1cc72068 100755 --- a/ansible/archival-snapshots/resources/set_env.sh +++ b/ansible/archival-snapshots/resources/set_env.sh @@ -10,8 +10,20 @@ ADMIN_TOKEN=$(cat admin_token) export FULLNODE_API_INFO="$ADMIN_TOKEN:/ip4/127.0.0.1/tcp/3456/http" # Save the environment variable to a file and source it -if echo "export FULLNODE_API_INFO=\"$FULLNODE_API_INFO\"" > ./forest-archival.env && source ./forest-archival.env; then - echo "Environment variable saved to and loaded from /tmp/forest-archival.env" +if echo "export FULLNODE_API_INFO=\"$FULLNODE_API_INFO\"" > ./forest-archival.env; then + echo "Environment variable saved to ./forest-archival.env" +else + echo "Failed to save environment variable to ./forest-archival.env" + exit 1 +fi + +# Check if the file exists before sourcing it +if [ -f "./forest-archival.env" ]; then + source ./forest-archival.env + echo "Environment variable loaded from ./forest-archival.env" +else + echo "Failed to load environment variable from ./forest-archival.env" + exit 1 fi # Use the environment variable