3 ##########################################
4 # WARNING WARNING WARNING WARNING
6 # This script is an example to start a new AGL XDS container
8 # You should customize it to fit your environment and in particular
9 # adjust the paths and permissions where needed.
11 # Note that sharing volumes with host system is not mandatory: it
12 # was just added for performances reasons: building from a SSD is
13 # just faster than using the container filesystem: that's why /xdt is
14 # mounted from there. Same applies to ~/mirror and ~/share, which are
15 # just 2 convenient folders to store reference build caches (used in prepare_meta script)
17 ##########################################
19 CURDIR=$(cd $(dirname $0) && pwd -P)
21 REGISTRY=docker.automotivelinux.org
27 # ---------------------------------------------------
28 # --- computed - don't touch !
29 # ---------------------------------------------------
32 DEFIMAGE=$REGISTRY/$REPO/$NAME-$FLAVOUR:$VERSION
35 echo "Usage: $(basename $0) <instance ID> [image name]" >&2
36 echo "Instance ID must be 0 or a positive integer (1,2,...)" >&2
37 echo "Image name is optional: 'make show-image' is used by default to get image" >&2
38 echo "Default image: $DEFIMAGE" >&2
45 while [ $# -ne 0 ]; do
54 if [[ "$1" =~ ^[0-9]+$ ]]; then
64 [ "$ID" = "" ] && usage
67 echo "Using instance ID #$ID (user $(id -un))"
69 NAME=agl-xds-$(hostname|cut -f1 -d'.')-$ID-$USER
71 MIRRORDIR=$HOME/ssd/localmirror_$ID
72 XDTDIR=$HOME/ssd/xdt_$ID
73 SHAREDDIR=$HOME/$DOCKER_USER/docker/share
75 SSH_PORT=$((2222 + ID))
76 WWW_PORT=$((8000 + ID))
77 BOOT_PORT=$((69 + ID))
78 NBD_PORT=$((10809 + ID))
80 mkdir -p $MIRRORDIR $XDTDIR $SHAREDDIR || exit 1
82 --publish=${SSH_PORT}:22 \
83 --publish=${WWW_PORT}:8000 \
84 --publish=${BOOT_PORT}:69/udp \
85 --publish=${NBD_PORT}:10809 \
87 --hostname=$NAME --name=$NAME \
88 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
89 -v $MIRRORDIR:/home/$DOCKER_USER/mirror \
90 -v $SHAREDDIR:/home/$DOCKER_USER/share \
93 if [ "$?" != "0" ]; then
94 echo "An error was encountered while creating docker container."
99 echo "Stoping xds-server..."
100 docker exec --user $DOCKER_USER ${NAME} bash -c "/usr/local/bin/xds-server-stop.sh" || exit 1
102 echo "Starting xds-server..."
103 docker exec --user $DOCKER_USER ${NAME} bash -c "nohup /usr/local/bin/xds-server-start.sh" || exit 1
106 echo "You can now login using:"
107 echo " ssh -p $SSH_PORT $DOCKER_USER@$(hostname)"