AutoDevReverseProxy/templates/hosts.sh
2023-01-18 15:02:13 +01:00

37 lines
792 B
Bash

#!/usr/bin/env bash
set -e
HOST_CONF_PATH="${HOST_CONF_PATH:-/config/hosts}"
RESOLVE_DOCKERHOST="${RESOLVE_DOCKERHOST:-false}"
DOCKER_HOSTNAME_VAR="${DOCKER_HOSTNAME_VAR:-LOCAL_WEB_HOST}"
if [ -f "${HOST_CONF_PATH}" ]
then
WRAP_START=$(grep -ve "# Added by hostman$" "${HOST_CONF_PATH}")
WRAP_START+="\n"
fi
if ! $RESOLVE_DOCKERHOST
then
TEMPLATE='127.0.0.1 '
else
TEMPLATE='$LOCAL_IP '
fi
TEMPLATE="${TEMPLATE}\${${DOCKER_HOSTNAME_VAR}} # Added by hostman"
# Allow overriding out for debugging and testing purposs
if [ -z "${HOST_CONF_OUT+.}" ]
then
OUT="${HOST_CONF_PATH}"
else
OUT="${HOST_CONF_OUT}"
fi
template_hook() {
if [[ "${PARTIAL_RESULT}" =~ ^(::|[.0-9a-e]+)+\ ([^ ]+\ )+\#\ Added\ by\ hostman$ ]]
then
return 0;
fi
return 1;
}