summaryrefslogtreecommitdiff
path: root/start-container-docker.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2017-09-05 14:08:22 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2017-09-06 07:20:49 +0000
commitc16fc6d3873cf327c9f28ca89d2d7760488f2354 (patch)
tree2fe82688f0246e9acea0ae161d50798592fc78aa /start-container-docker.sh
parentf0e51002706260e3cfb4bbcef92428fb23d800ac (diff)
start-container-docker.sh: Add --cp_file option
This option is targeted to be used by developers to replace /home/tcwg-buildslave/.ssh/authorized_keys inside container with developer's keys. E.g., this is how I start a QEMU container for ILP32 testing: WORKSPACE=`pwd` bash -x ./start-container-qemu.sh --cp_file ~/.ssh/authorized_keys:/home/tcwg-buildslave/.ssh/authorized_keys:tcwg-buildslave:0600 --task test --session-name qemu-2 --label tcwg-apm_64-build --node tcwg-apm-04 --distro xenial --prefix qemu_ --kernel_url https://cloud-images.ubuntu.com/releases/16.04/release/unpacked/ubuntu-16.04-server-cloudimg-arm64-vmlinuz-generic --initrd_url https://cloud-images.ubuntu.com/releases/16.04/release/unpacked/ubuntu-16.04-server-cloudimg-arm64-initrd-generic > qemu-container.sh Change-Id: I8e264616a55fbb1175d12eb0ebd82a03fca5e619
Diffstat (limited to 'start-container-docker.sh')
-rwxr-xr-xstart-container-docker.sh29
1 files changed, 28 insertions, 1 deletions
diff --git a/start-container-docker.sh b/start-container-docker.sh
index 7611b83b..1e7203a3 100755
--- a/start-container-docker.sh
+++ b/start-container-docker.sh
@@ -15,7 +15,7 @@ set -e
# - definition of ${session_host} and ${session_port}, can be used for
# a remote connexion to the container
usage() {
- echo "Usage: $0 [--arch container-arch] --distro flavour [--docker_opts opts] [--label label] [--node node] [--prefix prefix] [--session-host host] [--session-name name] [--task {build|test}] [--weight weight]"
+ echo "Usage: $0 [--arch container-arch] [--cp_file from[:to:owner:perms]] --distro flavour [--docker_opts opts] [--label label] [--node node] [--prefix prefix] [--session-host host] [--session-name name] [--task {build|test}] [--weight weight]"
echo
echo " container-arch: architecture (eg: amd64, i386, arm64, armhf)"
echo " distro: distribution (eg: trusty)"
@@ -37,6 +37,7 @@ exec 3>&1 4>&2
exec 1>&2
container_arch=
+cp_files=()
distro=
docker_opts=
label=
@@ -55,6 +56,11 @@ do
[ x${container_arch} = x ] && usage
shift 2
;;
+ --cp_file)
+ cp_files=("${cp_files[@]}" "$2")
+ [ x$2 = x ] && usage
+ shift 2
+ ;;
--distro)
distro=$2
[ x${distro} = x ] && usage
@@ -213,6 +219,27 @@ fi
CONTAINER_CLEANUP="$DOCKER rm -fv ${session_id}"
trap "exec 1>&3 2>&4 ; ${CONTAINER_CLEANUP}" EXIT
+for cp_file in "${cp_files[@]}"; do
+ from=$(echo "$cp_file" | cut -d: -f 1)
+ to=$(echo "$cp_file" | cut -s -d: -f 2)
+ owner=$(echo "cp_file" | cut -s -d: -f 3)
+ perms=$(echo "cp_file" | cut -s -d: -f 4)
+
+ if [ x"$to" = x"" ]; then
+ to="$from"
+ fi
+
+ $DOCKER cp "$from" "$session_id:$to"
+
+ if [ x"$owner" != x"" ]; then
+ $DOCKER exec "$session_id" chown "$owner" "$to"
+ fi
+
+ if [ x"$perms" != x"" ]; then
+ $DOCKER exec "$session_id" chmod "$perms" "$to"
+ fi
+done
+
session_port=$($DOCKER port $session_id 22 | cut -d: -f 2)
# Wait until the ssh server is ready to serve connexions