diff --git a/relay/process-compose-scripts/download-zk-and-dat-files.sh b/relay/process-compose-scripts/download-zk-and-dat-files.sh index 7b86a5609..a97934386 100755 --- a/relay/process-compose-scripts/download-zk-and-dat-files.sh +++ b/relay/process-compose-scripts/download-zk-and-dat-files.sh @@ -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