diff --git a/Dockerfile b/Dockerfile index d9a5886..e72cd91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,9 +69,11 @@ WORKDIR /root RUN set -e; \ echo "Setting up prerequisites"; \ yum makecache && yum install -yy bash; \ - BASH_CMD="$(command -v bash 2>/dev/null|| true)"; \ - [ -x "$BASH_CMD" ] && { rm -rf "/bin/sh" || true; } && ln -sf "$BASH_CMD" "/bin/sh" || true; \ - [ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true + SH_CMD="$(which sh 2>/dev/null)"; \ + BASH_CMD="$(which bash 2>/dev/null)"; \ + [ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true; \ + [ -x "$BASH_CMD" ] && [ "$SH_CMD" != "/bin/sh" ] && { rm -Rf "$SH_CMD";ln -s "$BASH_CMD" "$SH_CMD"; } || true; \ + [ -x "$BASH_CMD" ] && [ ! -L "/bin/sh" ] && { rm -rf "/bin/sh" || true; } && ln -sf "$BASH_CMD" "/bin/sh" || true ENV SHELL="/bin/bash" SHELL [ "/bin/bash", "-c" ] diff --git a/Dockerfile.8 b/Dockerfile.8 index 47c8436..c23e9c0 100644 --- a/Dockerfile.8 +++ b/Dockerfile.8 @@ -69,9 +69,11 @@ WORKDIR /root RUN set -e; \ echo "Setting up prerequisites"; \ yum makecache && yum install -yy bash; \ - BASH_CMD="$(command -v bash 2>/dev/null|| true)"; \ - [ -x "$BASH_CMD" ] && { rm -rf "/bin/sh" || true; } && ln -sf "$BASH_CMD" "/bin/sh" || true; \ - [ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true + SH_CMD="$(which sh 2>/dev/null)"; \ + BASH_CMD="$(which bash 2>/dev/null)"; \ + [ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true; \ + [ -x "$BASH_CMD" ] && [ "$SH_CMD" != "/bin/sh" ] && { rm -Rf "$SH_CMD";ln -s "$BASH_CMD" "$SH_CMD"; } || true; \ + [ -x "$BASH_CMD" ] && [ ! -L "/bin/sh" ] && { rm -rf "/bin/sh" || true; } && ln -sf "$BASH_CMD" "/bin/sh" || true ENV SHELL="/bin/bash" SHELL [ "/bin/bash", "-c" ] diff --git a/Dockerfile.9 b/Dockerfile.9 index 0cbb86b..32578a7 100644 --- a/Dockerfile.9 +++ b/Dockerfile.9 @@ -69,9 +69,11 @@ WORKDIR /root RUN set -e; \ echo "Setting up prerequisites"; \ yum makecache && yum install -yy bash; \ - BASH_CMD="$(command -v bash 2>/dev/null|| true)"; \ - [ -x "$BASH_CMD" ] && { rm -rf "/bin/sh" || true; } && ln -sf "$BASH_CMD" "/bin/sh" || true; \ - [ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true + SH_CMD="$(which sh 2>/dev/null)"; \ + BASH_CMD="$(which bash 2>/dev/null)"; \ + [ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true; \ + [ -x "$BASH_CMD" ] && [ "$SH_CMD" != "/bin/sh" ] && { rm -Rf "$SH_CMD";ln -s "$BASH_CMD" "$SH_CMD"; } || true; \ + [ -x "$BASH_CMD" ] && [ ! -L "/bin/sh" ] && { rm -rf "/bin/sh" || true; } && ln -sf "$BASH_CMD" "/bin/sh" || true ENV SHELL="/bin/bash" SHELL [ "/bin/bash", "-c" ]