#!/bin/bash
APPLICATION_PROBABILITY=${APPLICATION_PROBABILITY:-100}
FORCE_TO_PRESTABLE_SECRET=${FORCE_TO_PRESTABLE_SECRET:-prestable}

function replace_env() {
    env_name=$1
    file=/etc/nginx/$2
    env $env_name="${!env_name}" \
    envsubst '$'"$1" < $file > /tmp/nginx_file && mv /tmp/nginx_file $file
}

replace_env APPLICATION_PROBABILITY sites-enabled/app.conf
replace_env FORCE_TO_PRESTABLE_SECRET sites-enabled/app.conf
