diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-06-12 14:57:05 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-06-12 14:57:05 +0000 |
commit | 4ba35a39be2502794ded7c8398c3c8412260df34 (patch) | |
tree | 0cb32e169ba6800e804f28d85538a4bc99d16ce0 /tcwg-base | |
parent | d6226acc15d10d048341ee622eff309b76203f55 (diff) |
tcwg-host: Move addition of users to container init
... to allow group-based host containers. E.g., allow only LLVM devs
to LLVM buildbots.
Change-Id: Ie929e50f919132bd27ca356ca6b8d86c8d0f6b95
Diffstat (limited to 'tcwg-base')
-rw-r--r-- | tcwg-base/tcwg-host/Dockerfile.in | 11 | ||||
-rwxr-xr-x | tcwg-base/tcwg-host/build.sh | 4 | ||||
-rwxr-xr-x | tcwg-base/tcwg-host/run.sh | 22 | ||||
-rwxr-xr-x | tcwg-base/tcwg-host/start.sh | 3 |
4 files changed, 33 insertions, 7 deletions
diff --git a/tcwg-base/tcwg-host/Dockerfile.in b/tcwg-base/tcwg-host/Dockerfile.in index 4c001308..3c6de198 100644 --- a/tcwg-base/tcwg-host/Dockerfile.in +++ b/tcwg-base/tcwg-host/Dockerfile.in @@ -1,7 +1,10 @@ FROM linaro/ci-#{ARCH}-tcwg-base-ubuntu:#{DISTRO} -RUN while read line; do \ - new-user.sh --passwd "$line"; \ - done </home-data/passwd +COPY run.sh start.sh / -COPY start.sh / +#if ARCH_amd64 || ARCH_arm64 +ENTRYPOINT ["/run.sh"] +#else +ENTRYPOINT ["linux32", "/run.sh"] +#endif +CMD ["start.sh"] diff --git a/tcwg-base/tcwg-host/build.sh b/tcwg-base/tcwg-host/build.sh index b51c067a..60674195 100755 --- a/tcwg-base/tcwg-host/build.sh +++ b/tcwg-base/tcwg-host/build.sh @@ -6,7 +6,7 @@ trap cleanup_exit INT TERM EXIT cleanup_exit() { - rm -rf start.sh + rm -rf run.sh start.sh } export LANG=C @@ -16,7 +16,7 @@ name=$(basename ${PWD} | cut -f3- -d '-') image=linaro/ci-${arch}-${name}-ubuntu:${distro} top=$(git rev-parse --show-toplevel) -cp $top/tcwg-base/tcwg-host/start.sh ./ +cp $top/tcwg-base/tcwg-host/run.sh $top/tcwg-base/tcwg-host/start.sh ./ (cd ..; ./build.sh) "$top"/tcwg-base/validate-dockerfile.sh Dockerfile diff --git a/tcwg-base/tcwg-host/run.sh b/tcwg-base/tcwg-host/run.sh new file mode 100755 index 00000000..7149a3b9 --- /dev/null +++ b/tcwg-base/tcwg-host/run.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +if [ x"$1" = x"start.sh" ]; then + cat /start.sh + exit 0 +fi + +case "$1" in + "all") + while read line; do + new-user.sh --update true --passwd "$line" + done </home-data/passwd + ;; + *) + echo "ERROR: Unknown group $1" + exit 1 + ;; +esac + +exec /usr/sbin/sshd -D diff --git a/tcwg-base/tcwg-host/start.sh b/tcwg-base/tcwg-host/start.sh index e730d95a..e4c739c9 100755 --- a/tcwg-base/tcwg-host/start.sh +++ b/tcwg-base/tcwg-host/start.sh @@ -26,6 +26,7 @@ while [ $# -gt 0 ]; do done image="$1" +shift if $verbose; then set -x @@ -56,4 +57,4 @@ mounts="$mounts -v $(which docker):$(which docker)" # Use at most half of all available RAM. memlimit=$(($(free -g | awk '/^Mem/ { print $2 }') / 2))G -$DOCKER run -dt -p 2222:22 --name=host --hostname=$(hostname)-dckr $mounts --memory=$memlimit --pids-limit=5000 --restart=unless-stopped $image +$DOCKER run -dt -p 2222:22 --name=host --hostname=$(hostname)-dckr $mounts --memory=$memlimit --pids-limit=5000 --restart=unless-stopped $image "$@" |