Bump docker container version to 4.0 and update doc.
[src/xds/xds-server.git] / scripts / xds-docker-create-container.sh
index 46dde96..d041a22 100755 (executable)
@@ -22,7 +22,7 @@ REGISTRY=docker.automotivelinux.org
 REPO=agl
 NAME=worker
 FLAVOUR=xds
-VERSION=3.99.1
+VERSION=4.0
 
 # ---------------------------------------------------
 # --- computed - don't touch !
@@ -61,7 +61,11 @@ while [ $# -ne 0 ]; do
     shift
 done
 
-[ "$ID" = "" ] && usage
+[ "$ID" = "" ] && ID=0
+
+docker ps -a |grep "$IMAGE" > /dev/null
+[ "$?" = "0" ] && { echo "Image name already exist ! (use -h option to read help)"; exit 1; }
+
 
 USER=$(id -un)
 echo "Using instance ID #$ID (user $(id -un))"
@@ -103,5 +107,26 @@ if ($FORCE); then
     docker exec --user $DOCKER_USER  ${NAME} bash -c "nohup /usr/local/bin/xds-server-start.sh" || exit 1
 fi
 
+echo "Copying your identity to container $NAME"
+#wait ssh service
+echo -n wait ssh service .
+res=3
+max=30
+count=0
+while [ $res -ne 0 ] && [ $count -le $max ]; do
+    sleep 1
+    docker exec ${NAME} bash -c "systemctl status ssh" 2>/dev/null 1>&2 
+    res=$?
+    echo -n "."
+    count=$(expr $count + 1);
+done
+echo
+
+ssh-keygen -R [$(hostname)]:$SSH_PORT -f ~/.ssh/known_hosts
+docker exec ${NAME} bash -c "mkdir -p /home/devel/.ssh"
+docker cp ~/.ssh/id_rsa.pub ${NAME}:/home/devel/.ssh/authorized_keys
+docker exec ${NAME} bash -c "chown devel:devel -R /home/devel/.ssh ;chmod 0700 /home/devel/.ssh;chmod 0600 /home/devel/.ssh/*"
+ssh -o StrictHostKeyChecking=no -p $SSH_PORT devel@$(hostname) exit
+
 echo "You can now login using:"
 echo "   ssh -p $SSH_PORT $DOCKER_USER@$(hostname)"