]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
automation: introduce a new variable to control container user
authorWei Liu <wei.liu2@citrix.com>
Tue, 25 Sep 2018 14:19:31 +0000 (15:19 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 26 Sep 2018 08:50:17 +0000 (09:50 +0100)
Sometimes it is handy to create a container and play with its setup
manually as root.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
automation/build/README.md
automation/scripts/containerize

index bf113175f4b5e342b567aa6aedc058c87bac9bd3..f6cfd46f1ec6fb7801ccb6cb49951d4c0f9ec46e 100644 (file)
@@ -50,6 +50,8 @@ understands.
 - CONTAINER_ARGS: Allows you to pass extra arguments to Docker
   when starting the container.
 
+- CONTAINER_UID0: This specifies whether root is used inside the container.
+
 - XEN_CONFIG_EXPERT: If this is defined in your shell it will be
   automatically passed through to the container.
 
index bf9af589a800b0c9208ee5f587a11702ea861fa8..aa08274eba4d496e8515aa13f9ac2a8da71483c5 100755 (executable)
@@ -23,6 +23,12 @@ case "_${CONTAINER}" in
     _stretch|_) CONTAINER="${BASE}/debian:stretch" ;;
 esac
 
+# Use this variable to control whehter root should be used
+case "_${CONTAINER_UID0}" in
+    _1)   userarg= ;;
+    _0|_) userarg="-u $(id -u)" ;;
+esac
+
 # Save the commands for future use
 cmd=$@
 
@@ -70,7 +76,7 @@ fi
 # Kick off Docker
 einfo "*** Launching container ..."
 exec docker run \
-    -u $(id -u) \
+    ${userarg} \
     ${SSH_AUTH_SOCK:+-e SSH_AUTH_SOCK="/tmp/ssh-agent/${SSH_AUTH_NAME}"} \
     -v "${CONTAINER_PATH}":/build:rw \
     -v "${HOME}/.ssh":/root/.ssh:ro \