aboutsummaryrefslogtreecommitdiffstats
path: root/create_container
diff options
context:
space:
mode:
authorStephane Desneux <stephane.desneux@iot.bzh>2016-11-30 23:33:40 +0100
committerStephane Desneux <stephane.desneux@iot.bzh>2016-11-30 23:43:45 +0100
commit5e50ec8d65705b41140d06ec13611f0b3108f7b9 (patch)
tree8e7f30d8c883ac401e0d02962bff05be3e66f06d /create_container
parent7417e97927e5a06dddb3d2166e5ccc06a1a16aae (diff)
more fixes: apt more robust, versioning support, create_container script
Change-Id: Id4d8b93c935d27919aa945660ad614f8c73368de Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
Diffstat (limited to 'create_container')
-rwxr-xr-xcreate_container59
1 files changed, 59 insertions, 0 deletions
diff --git a/create_container b/create_container
new file mode 100755
index 0000000..74c7dc7
--- /dev/null
+++ b/create_container
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+CURDIR=$(cd $(dirname $0) && pwd -P)
+DEFIMAGE=$(make -s -C $CURDIR show-image)
+
+function usage() {
+ echo "Usage: $(basename $0) <instance ID> [image name]" >&2
+ echo "Instance ID must be 0 or a positive integer (1,2,...)" >&2
+ echo "Image name is optional: 'make show-image' is used by default to get image" >&2
+ echo "Default image: $DEFIMAGE" >&2
+ exit 1
+}
+
+case $1 in
+ -h|--help|"")
+ usage
+ ;;
+esac
+
+CURDIR=$(cd $(dirname $0) && pwd -P)
+
+ID=$1
+IMAGE=${2:-$DEFIMAGE}
+
+USER=$(id -un)
+echo "Using instance ID #$ID (user $(id -un))"
+
+NAME=agl-worker-$(hostname|cut -f1 -d'.')-$ID-$USER
+
+MIRRORDIR=$HOME/ssd/localmirror_$ID
+XDTDIR=$HOME/ssd/xdt_$ID
+SHAREDDIR=$HOME/devel/docker/share
+
+SSH_PORT=$((2222 + ID))
+WWW_PORT=$((8000 + ID))
+BOOT_PORT=$((69 + ID))
+NBD_PORT=$((10809 + ID))
+
+mkdir -p $MIRRORDIR $XDTDIR $SHAREDDIR
+docker run \
+ --publish=${SSH_PORT}:22 \
+ --publish=${WWW_PORT}:8000 \
+ --publish=${BOOT_PORT}:69/udp \
+ --publish=${NBD_PORT}:10809 \
+ --detach=true \
+ --hostname=$NAME --name=$NAME \
+ --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
+ -v $MIRRORDIR:/home/devel/mirror \
+ -v $SHAREDDIR:/home/devel/share \
+ -v $XDTDIR:/xdt \
+ -it docker.automotivelinux.org/agl/worker:2.1
+
+echo "Copying your identity to container $NAME:"
+sleep 5
+ssh-copy-id -p $SSH_PORT devel@$(hostname)
+
+echo "You can now login using:"
+echo " ssh -p $SSH_PORT devel@$(hostname)"
+