diff --git a/templates/caddy.sh b/templates/caddy.sh index 7333694..665c9f4 100644 --- a/templates/caddy.sh +++ b/templates/caddy.sh @@ -11,10 +11,15 @@ OUT='/config/Caddyfile' label_hook() { LOCAL_WEB_PORT="${LOCAL_WEB_PORT:-80}" + # Check if host contains spaces + if [[ "${LOCAL_WEB_HOST}" =~ \ ]] + then + LOCAL_WEB_HOST="$(sed 's/ /, /g' <<< ${LOCAL_WEB_HOST})" + fi } template_hook() { - if grep -q '^[^ ]\+ {\\n\\treverse_proxy \(?::\|[.0-9a-e]\)\+\:[0-9]\+\\n}$' <<< "${PARTIAL_RESULT}" + if [[ "${PARTIAL_RESULT}" =~ ^([^\{,\ ]+(,\ )?)+\ \{$'\\n\\t'reverse_proxy\ (::|[.0-9a-e]+)+\:[0-9]+$'\\n'\}$ ]] then return 0; fi diff --git a/templates/hosts.sh b/templates/hosts.sh index 810440c..7c8e2df 100644 --- a/templates/hosts.sh +++ b/templates/hosts.sh @@ -8,10 +8,6 @@ if [ -f "${HOST_CONF_PATH}" ] then WRAP_START=$(grep -ve "# Added by hostman$" "${HOST_CONF_PATH}") WRAP_START+="\n" -else - printf "[WARN]: No such file or directory: %s\n" "${HOST_CONF_PATH}" - printf "Creating %s" "${HOST_CONF_PATH}" - touch "${HOST_CONF_PATH}" fi if ! $RESOLVE_DOCKERHOST @@ -32,7 +28,7 @@ else fi template_hook() { - if grep -q '^[:.0-9a-e]\+ [^ ]\+ # Added by hostman$' <<< "${PARTIAL_RESULT}" + if [[ "${PARTIAL_RESULT}" =~ ^(::|[.0-9a-e]+)+\ ([^ ]+\ )+\#\ Added\ by\ hostman$ ]] then return 0; fi