From 9ef05f8623ee33bc4b07c9d317685f352796e6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Mon, 3 Oct 2022 18:05:11 +0000 Subject: [PATCH] Exec Bash just after sourcing stolon env --- Dockerfile | 2 +- scripts/set-stolon-environment.sh | 5 ----- scripts/shell-init | 11 +++++++++++ 3 files changed, 12 insertions(+), 6 deletions(-) delete mode 100755 scripts/set-stolon-environment.sh create mode 100755 scripts/shell-init diff --git a/Dockerfile b/Dockerfile index c67def1e..f4d7b5fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,7 +56,7 @@ RUN useradd -ms /bin/bash stolon RUN mkdir -p /run/haproxy/ COPY --from=flyutil /fly/bin/* /usr/local/bin/ -ENV ENV="/fly/set-stolon-environment.sh" +ENV ENV="/fly/shell-init" EXPOSE 5432 diff --git a/scripts/set-stolon-environment.sh b/scripts/set-stolon-environment.sh deleted file mode 100755 index 1bcc6538..00000000 --- a/scripts/set-stolon-environment.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -if [ -f /data/.env ]; then - export $(cat /data/.env) -fi diff --git a/scripts/shell-init b/scripts/shell-init new file mode 100755 index 00000000..898b164b --- /dev/null +++ b/scripts/shell-init @@ -0,0 +1,11 @@ +#!/bin/dash +# Dash sources this file according to POSIX envvar $ENV declared in Dockerfile +# https://manpages.debian.org/stretch/dash/dash.1.en.html#Invocation + +if [ -f /data/.env ]; then + export $(cat /data/.env) +fi + +# Upgrade to Bash shell +unset ENV +exec /bin/bash "$@"