summaryrefslogtreecommitdiffstats
path: root/aai-common-docker/aai-haproxy-image/src/main/docker/docker-entrypoint.sh
diff options
context:
space:
mode:
authorJames Forsyth <jf2512@att.com>2019-08-15 17:10:36 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-15 17:10:36 +0000
commit55228282b74da3ee98619fbb4604d0f21a75cf4c (patch)
treeabb60eff8c42e4796c7a026e675fdde822c509f9 /aai-common-docker/aai-haproxy-image/src/main/docker/docker-entrypoint.sh
parentb6169d1ab53f9264a181fef03be77fcd2bf02976 (diff)
parent649585b88b758d5c3e702446385ffe733ceea824 (diff)
Merge "Created maven modules for aai-common docker images."
Diffstat (limited to 'aai-common-docker/aai-haproxy-image/src/main/docker/docker-entrypoint.sh')
-rw-r--r--aai-common-docker/aai-haproxy-image/src/main/docker/docker-entrypoint.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/aai-common-docker/aai-haproxy-image/src/main/docker/docker-entrypoint.sh b/aai-common-docker/aai-haproxy-image/src/main/docker/docker-entrypoint.sh
new file mode 100644
index 00000000..9095b3d1
--- /dev/null
+++ b/aai-common-docker/aai-haproxy-image/src/main/docker/docker-entrypoint.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+set -e
+
+# first arg is `-f` or `--some-option`
+if [ "${1#-}" != "$1" ]; then
+ set -- haproxy "$@"
+fi
+
+NAMESERVER_IP=$(cat /etc/resolv.conf | grep 'nameserver' | head -1 | awk '{ print $2; }');
+
+sed -i 's/${ONAP_NAMESERVER_CLUSTER_IP}/'${NAMESERVER_IP}'/g' /usr/local/etc/haproxy/resolvers.conf || {
+ echo "Unable to overwrite the nameserver in the haproxy configuration file";
+ exit 1;
+}
+
+if [ "$1" = 'haproxy' ]; then
+ # if the user wants "haproxy", let's use "haproxy-systemd-wrapper" instead so we can have proper reloadability implemented by upstream
+ shift # "haproxy"
+ set -- "$(which haproxy-systemd-wrapper)" -p /run/haproxy.pid "$@"
+fi
+
+exec "$@"