aboutsummaryrefslogtreecommitdiffstats
path: root/archive/msb/components/msb-consul/resources
diff options
context:
space:
mode:
authorAndreas Geissler <andreas-geissler@telekom.de>2024-08-13 09:59:22 +0200
committerAndreas Geissler <andreas-geissler@telekom.de>2024-08-13 13:22:12 +0200
commit8c66f85d7348b09de54b7479757878d96f1c1cd0 (patch)
treeb4d27de208bbc49ba82a33a2404cc525ca1a2059 /archive/msb/components/msb-consul/resources
parent2ce0437988709fd8af46c8f922f1d22d312e49f9 (diff)
[COMMON] Cleanup charts
- archive charts, which are not maintained anymore - archive subcharts in SDNC, MSB, DCAEGEN2-SERVICES - Cleanup environment and override files Issue-ID: OOM-3309 Issue-ID: ONAPARC-805 Change-Id: If19a807fefa574ceb9b90ac1eb84d9642729323d Signed-off-by: Andreas Geissler <andreas-geissler@telekom.de>
Diffstat (limited to 'archive/msb/components/msb-consul/resources')
-rwxr-xr-xarchive/msb/components/msb-consul/resources/docker-entrypoint.sh95
1 files changed, 95 insertions, 0 deletions
diff --git a/archive/msb/components/msb-consul/resources/docker-entrypoint.sh b/archive/msb/components/msb-consul/resources/docker-entrypoint.sh
new file mode 100755
index 0000000000..18692d8afa
--- /dev/null
+++ b/archive/msb/components/msb-consul/resources/docker-entrypoint.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+#!/usr/bin/dumb-init /bin/sh
+# As of docker 1.13, using docker run --init achieves the same outcome than dumb-init.
+
+set -e
+set -x
+
+CONSUL_BIND=
+if [ -n "$CONSUL_BIND_INTERFACE" ]; then
+ CONSUL_BIND_ADDRESS=$(ip -o -4 addr list $CONSUL_BIND_INTERFACE | head -n1 | awk '{print $4}' | cut -d/ -f1)
+ if [ -z "$CONSUL_BIND_ADDRESS" ]; then
+ echo "Could not find IP for interface '$CONSUL_BIND_INTERFACE', exiting"
+ exit 1
+ fi
+
+ CONSUL_BIND="-bind=$CONSUL_BIND_ADDRESS"
+ echo "==> Found address '$CONSUL_BIND_ADDRESS' for interface '$CONSUL_BIND_INTERFACE', setting bind option..."
+fi
+
+# You can set CONSUL_CLIENT_INTERFACE to the name of the interface you'd like to
+# bind client intefaces (HTTP, DNS, and RPC) to and this will look up the IP and
+# pass the proper -client= option along to Consul.
+CONSUL_CLIENT=
+if [ -n "$CONSUL_CLIENT_INTERFACE" ]; then
+ CONSUL_CLIENT_ADDRESS=$(ip -o -4 addr list $CONSUL_CLIENT_INTERFACE | head -n1 | awk '{print $4}' | cut -d/ -f1)
+ if [ -z "$CONSUL_CLIENT_ADDRESS" ]; then
+ echo "Could not find IP for interface '$CONSUL_CLIENT_INTERFACE', exiting"
+ exit 1
+ fi
+
+ CONSUL_CLIENT="-client=$CONSUL_CLIENT_ADDRESS"
+ echo "==> Found address '$CONSUL_CLIENT_ADDRESS' for interface '$CONSUL_CLIENT_INTERFACE', setting client option..."
+fi
+
+# CONSUL_DATA_DIR is exposed as a volume for possible persistent storage. The
+# CONSUL_CONFIG_DIR isn't exposed as a volume but you can compose additional
+# config files in there if you use this image as a base, or use CONSUL_LOCAL_CONFIG
+# below.
+CONSUL_DATA_DIR=/consul/data
+CONSUL_CONFIG_DIR=/consul/config
+
+# You can also set the CONSUL_LOCAL_CONFIG environemnt variable to pass some
+# Consul configuration JSON without having to bind any volumes.
+if [ -n "$CONSUL_LOCAL_CONFIG" ]; then
+ echo "$CONSUL_LOCAL_CONFIG" > "$CONSUL_CONFIG_DIR/local.json"
+fi
+
+# If the user is trying to run Consul directly with some arguments, then
+# pass them to Consul.
+if echo "$1" | grep '^-' >/dev/null; then
+ set -- consul "$@"
+fi
+
+# Look for Consul subcommands.
+if [ "$1" = 'agent' ]; then
+ shift
+ set -- consul agent \
+ -data-dir="$CONSUL_DATA_DIR" \
+ -config-dir="$CONSUL_CONFIG_DIR" \
+ $CONSUL_BIND \
+ $CONSUL_CLIENT \
+ "$@"
+elif [ "$1" = 'version' ]; then
+ # This needs a special case because there's no help output.
+ set -- consul "$@"
+elif consul --help "$1" 2>&1 | grep -q "consul $1"; then
+ # We can't use the return code to check for the existence of a subcommand, so
+ # we have to use grep to look for a pattern in the help output.
+ set -- consul "$@"
+fi
+
+# If we are running Consul, make sure it executes as the proper user.
+if [ "$1" = 'consul' ]; then
+ # If the data or config dirs are bind mounted then chown them.
+ # Note: This checks for root ownership as that's the most common case.
+ if [ "$(stat -c %u /consul/data)" != "$(id -u consul)" ]; then
+ chown consul:consul /consul/data
+ fi
+ if [ "$(stat -c %u /consul/config)" != "$(id -u consul)" ]; then
+ chown consul:consul /consul/config
+ fi
+
+ # If requested, set the capability to bind to privileged ports before
+ # we drop to the non-root user. Note that this doesn't work with all
+ # storage drivers (it won't work with AUFS).
+ if [ ! -z ${CONSUL_ALLOW_PRIVILEGED_PORTS+x} ]; then
+ setcap "cap_net_bind_service=+ep" /bin/consul
+ fi
+
+# Instead of using this we run our pod as a non-root user.
+# set -- su-exec consul:consul "$@"
+fi
+
+exec "$@"