2015-09-11 22:05:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2015-09-12 07:18:12 -07:00
|
|
|
# Warn if the DOCKER_HOST socket does not exist
|
2017-01-11 22:39:04 -05:00
|
|
|
if [[ $DOCKER_HOST = unix://* ]]; then
|
2015-09-12 07:18:12 -07:00
|
|
|
socket_file=${DOCKER_HOST#unix://}
|
2021-04-29 03:18:40 +02:00
|
|
|
if ! [ -S "$socket_file" ]; then
|
2015-09-12 07:18:12 -07:00
|
|
|
cat >&2 <<-EOT
|
|
|
|
ERROR: you need to share your Docker host socket with a volume at $socket_file
|
2021-04-01 16:06:09 +02:00
|
|
|
Typically you should run your nginxproxy/nginx-proxy with: \`-v /var/run/docker.sock:$socket_file:ro\`
|
2015-09-12 07:18:12 -07:00
|
|
|
See the documentation at http://git.io/vZaGJ
|
|
|
|
EOT
|
|
|
|
socketMissing=1
|
2015-09-11 22:05:54 +00:00
|
|
|
fi
|
2015-09-12 07:18:12 -07:00
|
|
|
fi
|
2015-09-12 10:37:21 +00:00
|
|
|
|
2017-01-11 22:39:04 -05:00
|
|
|
# Generate dhparam file if required
|
2021-04-29 03:18:04 +02:00
|
|
|
/app/generate-dhparam.sh
|
2017-01-11 22:39:04 -05:00
|
|
|
|
2017-10-19 20:58:34 -04:00
|
|
|
# Compute the DNS resolvers for use in the templates - if the IP contains ":", it's IPv6 and must be enclosed in []
|
2021-04-29 03:18:40 +02:00
|
|
|
RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g'); export RESOLVERS
|
|
|
|
if [ "$RESOLVERS" = "" ]; then
|
2016-10-01 10:42:58 -04:00
|
|
|
echo "Warning: unable to determine DNS resolvers for nginx" >&2
|
2017-02-06 18:20:54 +08:00
|
|
|
unset RESOLVERS
|
2016-10-01 10:42:58 -04:00
|
|
|
fi
|
|
|
|
|
2015-09-12 07:18:12 -07:00
|
|
|
# If the user has run the default command and the socket doesn't exist, fail
|
2021-04-29 03:18:40 +02:00
|
|
|
if [ "$socketMissing" = 1 ] && [ "$1" = forego ] && [ "$2" = start ] && [ "$3" = '-r' ]; then
|
2015-09-12 07:18:12 -07:00
|
|
|
exit 1
|
2015-09-11 22:05:54 +00:00
|
|
|
fi
|
|
|
|
|
2015-09-12 10:37:21 +00:00
|
|
|
exec "$@"
|