summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjin.xiao <jin.xiao@samsung.com>2019-04-22 14:50:56 +0800
committerjin.xiao <jin.xiao@samsung.com>2019-04-22 14:50:56 +0800
commit383d243c6ac85e420f93ce60467d2e0f8e5988f1 (patch)
treeddc37e839bd9b7d2fc1c6d82e47536d97567eb58
parent08f3e2976ea26ae7db0668a65e0d0bf09c78a4be (diff)
downloaddocker-script-tizentools-containers.tar.gz
docker-script-tizentools-containers.tar.bz2
docker-script-tizentools-containers.zip
Image creation using multiple mic PDKtizentools-containers
Change-Id: I350051164921d51f3477a5f4a28ab3834e59b082
-rwxr-xr-xDockerfile51
-rwxr-xr-xpdkcommon-client-189
-rwxr-xr-xpdkcommon-client-289
-rwxr-xr-xpdkcommon-server89
4 files changed, 318 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100755
index 0000000..a075d2e
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,51 @@
+FROM ubuntu:16.04
+
+MAINTAINER Zhang Yang <y0169.zhang@samsung.com>, Jun Wang <junbill.wang@samsung.com>
+
+ADD start_gbs /usr/bin/start_gbs
+
+RUN set -xe \
+
+ && apt-get update \
+
+ && apt-get install -y vim git unzip kpartx curl git software-properties-common sudo unzip vim wget net-tools\
+
+ && wget http://download.tizen.org/sdk/tizenstudio/official/binary/sdb_2.3.0_ubuntu-64.zip\
+
+ && unzip sdb_2.3.0_ubuntu-64.zip\
+
+ && cp data/tools/sdb /usr/bin/ \
+
+ && echo "deb [trusted=yes] http://10.113.136.113:82/Tools:/MicDockerTest/Ubuntu_16.04/ /" > /etc/apt/sources.list.d/tizen.list \
+
+ && echo "deb http://download.tizen.org/tools/archive/19.03/Ubuntu_16.04/ / " >> /etc/apt/sources.list.d/tizen.list \
+
+ && apt-get update \
+
+ && apt-get -o Dpkg::Options::="--force-overwrite" install -y --allow-unauthenticated gbs mic \
+ #Using sync command before exec /usr/lib/build/initvm.x86_64
+ && sed -i 'N;616i\\t sync' /usr/lib/build/init_buildsystem \
+
+ && rm -rf /var/cache/apt/ /var/cache/man /var/lib/apt /var/lib/apt/lists/* \
+
+ && useradd --create-home --no-log-init --shell /bin/bash robot \
+
+ && adduser robot sudo \
+
+ && echo 'robot:robot' | chpasswd \
+
+ && sed -i '$a\robot ALL = NOPASSWD: /usr/sbin/useradd, /usr/sbin/usermod, /usr/sbin/groupadd ,\
+
+ /bin/su -c /usr/bin/start_gbs *, \
+
+ /bin/su -c /usr/bin/mic *, \
+
+ /bin/su -c /usr/bin/sdb *, \
+
+ /bin/su -c /usr/bin/litmus *, \
+
+ /bin/su -c /usr/bin/lthor *' /etc/sudoers
+
+USER robot
+#ENV HOME /root
+ENV TERM xterm
diff --git a/pdkcommon-client-1 b/pdkcommon-client-1
new file mode 100755
index 0000000..176a84c
--- /dev/null
+++ b/pdkcommon-client-1
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+declare container_name="pdkcontainer-client-1"
+declare IMAGE="tizenpdk:v0.2"
+declare VOLUMES="-v /dev/bus/usb:/dev/bus/usb"
+#declare DEVICES="--devices=/dev/bus/usb"
+declare PRIVILEGE="--privileged"
+declare hostname=$(hostname)
+declare container_id
+VOLUMES=$(echo $VOLUMES "-v /etc/localtime:/etc/localtime:ro -v /etc/mic/:/etc/mic/")
+HOSTNAME=" --hostname $(hostname) "
+
+DirCheck()
+{
+ remain_array=(home share var srv root tmp)
+ for i in ${remain_array[@]}
+ do
+ re=$(ls / | grep -w $i)
+ if [ $re ]
+ then
+ VOLUMES="$VOLUMES --volume=/$re:/$re"
+ fi
+ done
+# echo $VOLUMES
+}
+
+PermissonCheck(){
+ docker ps >/dev/null
+ if [ $? -ne 0 ]
+ then
+ echo -e "\033[31m[Error]\033[0m:\033[33mYou haven't permission to run docker without 'sudo'.We suggest you to use docker without sudo. \033[0m"
+ exit
+ fi
+}
+
+# clear the $IMAGE container which is Exited status
+Autoclean(){
+ ids=$(docker ps -a | grep -w $IMAGE | grep -w 'Exited' | awk '{print $1}')
+ for id in $ids
+ do
+ docker rm $id 1>/dev/null
+ done
+}
+
+# delte a container by id or container name
+DeleteContainer()
+{
+ docker stop $1 >/dev/null 2>&1
+ if [ $?==0 ]
+ then
+ docker rm $1 >/dev/null 2>&1
+ fi
+}
+
+# create a container
+CreateContainer()
+{
+ #Check mounting
+# if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
+# mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
+# fi
+ container_id=$(docker run -itd --name=$1 --network=pdknet ${PRIVILEGE} ${VOLUMES} ${IMAGE} /bin/bash)
+}
+
+# check whether the container is exists
+CheckContainer()
+{
+ container_id=$(docker ps | grep -w $1 | awk '{print $1}')
+ #echo $container_id "test"
+ # after try 10 times, if container_id always is 0, then exit
+ i=0
+ while [ -z $container_id ]
+ do
+ CreateContainer $1
+ i=1
+ done
+ if [ $i -ne 1 ]
+ then
+ echo "Can't create container, please check"
+ exit 0
+ else
+ echo "create container" $container_id "successful"
+ fi
+}
+
+DirCheck
+PermissonCheck
+Autoclean
+CheckContainer $container_name
diff --git a/pdkcommon-client-2 b/pdkcommon-client-2
new file mode 100755
index 0000000..ebd16d5
--- /dev/null
+++ b/pdkcommon-client-2
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+declare container_name="pdkcontainer-client-2"
+declare IMAGE="tizenpdk:v0.2"
+declare VOLUMES="-v /dev/bus/usb:/dev/bus/usb"
+#declare DEVICES="--devices=/dev/bus/usb"
+declare PRIVILEGE="--privileged"
+declare hostname=$(hostname)
+declare container_id
+VOLUMES=$(echo $VOLUMES "-v /etc/localtime:/etc/localtime:ro -v /etc/mic/:/etc/mic/")
+HOSTNAME=" --hostname $(hostname) "
+
+DirCheck()
+{
+ remain_array=(home share var srv root tmp)
+ for i in ${remain_array[@]}
+ do
+ re=$(ls / | grep -w $i)
+ if [ $re ]
+ then
+ VOLUMES="$VOLUMES --volume=/$re:/$re"
+ fi
+ done
+# echo $VOLUMES
+}
+
+PermissonCheck(){
+ docker ps >/dev/null
+ if [ $? -ne 0 ]
+ then
+ echo -e "\033[31m[Error]\033[0m:\033[33mYou haven't permission to run docker without 'sudo'.We suggest you to use docker without sudo. \033[0m"
+ exit
+ fi
+}
+
+# clear the $IMAGE container which is Exited status
+Autoclean(){
+ ids=$(docker ps -a | grep -w $IMAGE | grep -w 'Exited' | awk '{print $1}')
+ for id in $ids
+ do
+ docker rm $id 1>/dev/null
+ done
+}
+
+# delte a container by id or container name
+DeleteContainer()
+{
+ docker stop $1 >/dev/null 2>&1
+ if [ $?==0 ]
+ then
+ docker rm $1 >/dev/null 2>&1
+ fi
+}
+
+# create a container
+CreateContainer()
+{
+ #Check mounting
+# if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
+# mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
+# fi
+ container_id=$(docker run -itd --name=$1 --network=pdknet ${PRIVILEGE} ${VOLUMES} ${IMAGE} /bin/bash)
+}
+
+# check whether the container is exists
+CheckContainer()
+{
+ container_id=$(docker ps | grep -w $1 | awk '{print $1}')
+ #echo $container_id "test"
+ # after try 10 times, if container_id always is 0, then exit
+ i=0
+ while [ -z $container_id ]
+ do
+ CreateContainer $1
+ i=1
+ done
+ if [ $i -ne 1 ]
+ then
+ echo "Can't create container, please check"
+ exit 0
+ else
+ echo "create container" $container_id "successful"
+ fi
+}
+
+DirCheck
+PermissonCheck
+#Autoclean
+CheckContainer $container_name
diff --git a/pdkcommon-server b/pdkcommon-server
new file mode 100755
index 0000000..1b16e3b
--- /dev/null
+++ b/pdkcommon-server
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+declare container_name="pdkcontainer-server"
+declare IMAGE="tizenpdk:v0.2"
+declare VOLUMES="-v /dev/bus/usb:/dev/bus/usb"
+#declare DEVICES="--devices=/dev/bus/usb"
+declare PRIVILEGE="--privileged"
+declare hostname=$(hostname)
+declare container_id
+VOLUMES=$(echo $VOLUMES "-v /etc/localtime:/etc/localtime:ro -v /etc/mic/:/etc/mic/")
+HOSTNAME=" --hostname $(hostname) "
+
+DirCheck()
+{
+ remain_array=(home share var srv root tmp)
+ for i in ${remain_array[@]}
+ do
+ re=$(ls / | grep -w $i)
+ if [ $re ]
+ then
+ VOLUMES="$VOLUMES --volume=/$re:/$re"
+ fi
+ done
+# echo $VOLUMES
+}
+
+PermissonCheck(){
+ docker ps >/dev/null
+ if [ $? -ne 0 ]
+ then
+ echo -e "\033[31m[Error]\033[0m:\033[33mYou haven't permission to run docker without 'sudo'.We suggest you to use docker without sudo. \033[0m"
+ exit
+ fi
+}
+
+# clear the $IMAGE container which is Exited status
+Autoclean(){
+ ids=$(docker ps -a | grep -w $IMAGE | grep -w 'Exited' | awk '{print $1}')
+ for id in $ids
+ do
+ docker rm $id 1>/dev/null
+ done
+}
+
+# delte a container by id or container name
+DeleteContainer()
+{
+ docker stop $1 >/dev/null 2>&1
+ if [ $?==0 ]
+ then
+ docker rm $1 >/dev/null 2>&1
+ fi
+}
+
+# create a container
+CreateContainer()
+{
+ #Check mounting
+# if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
+# mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
+# fi
+ container_id=$(docker run -itd --network=pdknet --name=$1 ${PRIVILEGE} ${VOLUMES} ${IMAGE} /bin/bash)
+}
+
+# check whether the container is exists
+CheckContainer()
+{
+ container_id=$(docker ps | grep -w $1 | awk '{print $1}')
+ #echo $container_id "test"
+ # after try 10 times, if container_id always is 0, then exit
+ i=0
+ while [ -z $container_id ]
+ do
+ CreateContainer $1
+ i=1
+ done
+ if [ $i -ne 1 ]
+ then
+ echo "Can't create container, please check"
+ exit 0
+ else
+ echo "create container" $container_id "successful"
+ fi
+}
+
+DirCheck
+PermissonCheck
+Autoclean
+CheckContainer $container_name