From be7932155ab2330ebdaf40b2fe65d1d549ba40b6 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 25 Sep 2015 10:20:38 -0700 Subject: [PATCH] Make impersonation switchable Useful when debugging issues with root vs non-root --- scripts/build-run.sh | 5 ++++- scripts/build-tty.sh | 3 ++- scripts/build.sh | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/build-run.sh b/scripts/build-run.sh index 9cbda2808a..c1cb25a6ff 100755 --- a/scripts/build-run.sh +++ b/scripts/build-run.sh @@ -8,9 +8,12 @@ DIR=/opt/monad-linux VOLUME=$(dirname $(pwd))/:$DIR # creates new user in container matching the local user so that -# artifacts will be owned by the local user (instead of root) +# artifacts will be owned by the local user; set IMPERSONATE to false +# to disable and run as root, defaults to true +if [[ ! $IMPERSONATE ]]; then IMPERSONATE=true; fi impersonate() { + if ! $IMPERSONATE; then return; fi echo \ groupadd -g $CGID $CGROUP '&&' \ useradd -u $CUID -g $CGID -d $DIR $CUSER '&&' \ diff --git a/scripts/build-tty.sh b/scripts/build-tty.sh index ad70fae863..d6dfcbea6d 100755 --- a/scripts/build-tty.sh +++ b/scripts/build-tty.sh @@ -1,4 +1,5 @@ #!/usr/bin/env sh # Runs with a pseudo tty so that interactive shells can be opened -DOCKERFLAGS="--interactive --tty" ./build-run.sh "$*" +export DOCKERFLAGS="--interactive --tty" +./build-run.sh "$*" diff --git a/scripts/build.sh b/scripts/build.sh index 225e5953f4..abf252cc22 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh -echo "$*" # Runs by non-interactively, just attaches output -DOCKERFLAGS="--attach STDOUT --attach STDERR" ./build-run.sh "$*" +export DOCKERFLAGS="--attach STDOUT --attach STDERR" +./build-run.sh "$*"