-
Notifications
You must be signed in to change notification settings - Fork 7
/
smarthomeng-knx-common.sh
80 lines (64 loc) · 1.5 KB
/
smarthomeng-knx-common.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
70
71
72
73
74
75
76
77
78
79
80
ACTION=$1
DOCKER_REPOSITORY_ID=smarthomeng
DOCKER_REPOSITORY=smarthome-ng
VERSION=1.7.2
IMAGE=$DOCKER_REPOSITORY_ID/$DOCKER_REPOSITORY:$VERSION
IMAGE_LATEST_TAG=$DOCKER_REPOSITORY_ID/$DOCKER_REPOSITORY:latest
CONTAINER_NAME=smarthomeng
smarthomengconfig=~/knx/visu/docker-configs/smarthome-ng-config
if [ -z "$ACTION" ];
then
echo "usage: $0 <build|tag|push|run|stop|start|remove|rerun|attach|logs>";
exit 1;
fi
_build() {
# Build
docker build -t $IMAGE -t $IMAGE_LATEST_TAG .
}
_tag() {
# tag => $ docker tag local-image:tagname reponame:tagname
docker tag $IMAGE $IMAGE_LATEST_TAG
}
_push() {
# $ docker push reponame:tagname
docker push $IMAGE && docker push $IMAGE_LATEST_TAG
}
_run() {
# Run (first time)
docker run -d \
-p 2323:2323 \
-p 2424:2424 \
-p 8383:8383 \
-v $smarthomengconfig/etc:/usr/local/smarthome/etc \
-v $smarthomengconfig/items:/usr/local/smarthome/items \
-v $smarthomengconfig/logics:/usr/local/smarthome/logics \
-v $smarthomengconfig/scenes:/usr/local/smarthome/scenes \
-v $smarthomengconfig/var:/usr/local/smarthome/var \
# -v /dev/ttyUSB0:/dev/ttyUSB0 \
--name=$CONTAINER_NAME \
-it $IMAGE
}
_stop() {
# Stop
docker stop $CONTAINER_NAME
}
_start() {
# Start (after stopping)
docker start $CONTAINER_NAME
}
_remove() {
# Remove
docker rm $CONTAINER_NAME
}
_rerun() {
_stop
_remove
_run
}
_attach() {
docker exec -ti $CONTAINER_NAME bash
}
_logs() {
docker logs $CONTAINER_NAME
}
eval _$ACTION