-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
70 lines (58 loc) · 1.96 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# This bash script is part of the COSItools setup procedure.
# It is licenced under the Apache 2.0 license
#
# Development lead: Andreas Zoglauer
#
# Description:
# This script creates and launches the COSItools docker.
# It assumes that you can run docker without sudo.
#
# Check if docker is installed
type docker >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "Error: Cannot find docker"
exit 1
fi
# Check if the docker daemon is running and accessible as user
STATUS=$(docker info 2>&1)
if [[ ${STATUS} == *ERROR* ]]; then
if [[ ${STATUS} == *Cannot\ connect\ to\ the\ Docker\ daemon* ]]; then
echo "Error: The docker daemon is not running"
exit 1;
fi
if [[ ${STATUS} == *permission\ denied* ]]; then
echo "Error: The docker daemon requires sudo, please set it up to not require sudo"
exit 1;
fi
# Unknown error
echo "Error: Something is up with docker:"
docker info
exit 1
fi
# Check if we need to rebuild the docker
echo "Checking if container rebuild is required"
docker build -t cosi-main - < Dockerfile
# Setup the exchange directory
EXCHANGE_DIRECTORY="${HOME}/COSIDockerData"
if [[ ! -d ${EXCHANGE_DIRECTORY} ]]; then
mkdir ${EXCHANGE_DIRECTORY}
fi
# Run docker
echo ""
echo ""
echo "Starting up docker, please wait..."
echo ""
if [[ $(uname -a) == *inux* ]]; then
XSOCK=/tmp/.X11-unix.${USER}
XAUTH=/tmp/.docker.xauth.${USER}
xauth nlist ${DISPLAY} | sed -e 's/^..../ffff/' | xauth -f ${XAUTH} nmerge -
docker run -v ${EXCHANGE_DIRECTORY}:/home/cosi/COSIDockerData -e DISPLAY=${DISPLAY} -v ${XSOCK}:${XSOCK} -v ${XAUTH}:${XAUTH} --net=host -e USERID=`id -u ${USER}` -e GROUPID=`id -g ${USER}` -it cosi-main
elif [[ $(uname -a) == *arwin* ]]; then
XSOCK=/tmp/.X11-unix.${USER}
YOUR_IP=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{ print $2 }')
xhost +${YOUR_IP}
docker run -v ${EXCHANGE_DIRECTORY}:/home/cosi/COSIDockerData -e DISPLAY=${YOUR_IP}:0 -v ${XSOCK}:${XSOCK} -it cosi-main
else
echo "Unsupported OS"
fi