Skip to content

Commit

Permalink
feat(relay): Add a check for host and port env and set them if not se…
Browse files Browse the repository at this point in the history
…t in `.env`
  • Loading branch information
kkirkov committed Aug 20, 2024
1 parent 593922b commit 72cbd31
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions relay/process-compose-scripts/download-zk-and-dat-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,29 @@ if [[ "${PRATTER}" != "TRUE" && "${MAINNET}" != "TRUE" ]]; then
echo "Neither PRATTER nor MAINNET is set or true."
exit 1
fi

# Function to update or add a variable in the .env file
update_env_var() {
local var_name=$1
local var_value=$2
local env_file="${GIT_ROOT}/.env"

# If the variable exists in the file, update it; otherwise, append it
if grep -q "^${var_name}=" "$env_file"; then
sed -i "s|^${var_name}=.*|${var_name}=${var_value}|" "$env_file"
else
echo "${var_name}=${var_value}" >> "$env_file"
fi
}

# Check if PROVER_SERVER_HOST is set in .env and if not set the default value
if [[ -z "${PROVER_SERVER_HOST}" ]]; then
PROVER_SERVER_HOST="http://127.0.0.1"
update_env_var "PROVER_SERVER_HOST" "${PROVER_SERVER_HOST}"
fi

# Check if PROVER_SERVER_PORT is set in .env and if not set the default value
if [[ -z "${PROVER_SERVER_PORT}" ]]; then
PROVER_SERVER_PORT="5000"
update_env_var "PROVER_SERVER_PORT" "${PROVER_SERVER_PORT}"
fi

0 comments on commit 72cbd31

Please sign in to comment.