summaryrefslogtreecommitdiff
path: root/pdkcommon-client-1
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 /pdkcommon-client-1
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
Diffstat (limited to 'pdkcommon-client-1')
-rwxr-xr-xpdkcommon-client-189
1 files changed, 89 insertions, 0 deletions
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