-
-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathdockerCreate.sh
More file actions
executable file
·61 lines (52 loc) · 980 Bytes
/
dockerCreate.sh
File metadata and controls
executable file
·61 lines (52 loc) · 980 Bytes
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
#!/bin/bash
# Script variables
DOCKER="sudo docker"
D_BUILD="$DOCKER build"
D_CONT="$DOCKER container"
D_CREATE="$DOCKER create"
# Configuration part
PORT=""
BLID=""
PASSWORD=""
ROBOT_IP=""
RET_VAL=""
read_if_empty()
{
if [ -z "${!1}" ] ; then
echo "Insert values for $1"
read
RET_VAL="${REPLY}"
return
fi
RET_VAL="${!1}"
}
read_if_empty PORT
PORT=$RET_VAL
read_if_empty BLID
BLID=$RET_VAL
read_if_empty PASSWORD
PASSWORD=$RET_VAL
read_if_empty ROBOT_IP
ROBOT_IP=$RET_VAL
# Docker environment
CONT_NAME=rest980
IMAGE_NAME=koalazak/rest980/local
exists () {
$1 ls -a | grep "$2"
}
$D_BUILD . -t $IMAGE_NAME
$D_CREATE \
--name=$CONT_NAME \
-p $PORT:3000 \
-e BLID=$BLID \
-e PASSWORD=$PASSWORD \
-e ROBOT_IP=$ROBOT_IP \
--restart always \
$IMAGE_NAME
exists "$D_CONT" $CONT_NAME
if [ 0 -eq $? ] ; then
echo "Creating container named: $CONT_NAME succeed."
$D_CONT start $CONT_NAME
else
echo "Failed to create container."
fi