-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-up
executable file
·40 lines (37 loc) · 1.25 KB
/
docker-up
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
#!/bin/sh
if test -n "$1"; then
VERSION=":$1"
fi
NAME="grafana"
cmd() {
echo Running "'$@'"
$@
if test 0 != $?; then
echo "FAILED... aborting."
exit $?
fi
}
IMAGE="grafana/grafana$VERSION"
ID=$(docker ps -q -f name=grafana)
RUNNING=$(docker ps --filter name=$NAME --format '{{.Image}}')
if test "$RUNNING" = "$IMAGE"; then
echo "Image $NAME already running at $ID"
elif test -n "$RUNNING"; then
echo "Image $NAME running w/ $RUNNING, you need delete it first."
echo "Run:"
echo "; docker stop $NAME"
echo "; docker rm $NAME"
exit 1
else
cmd docker run -p 3000:3000 -d -e GF_LOG_LEVEL=debug --name=$NAME $IMAGE
ID=$(docker ps -q -f name=grafana)
fi
SRC=$(dirname $0)
ID=$(docker ps -q -f name=grafana)
# We use user root here b/c of docker bugs w/ cp.
# Target files from the last run should be owned by grafana, alas they are not.
cmd docker exec --user=root -it $ID rm -rf /var/lib/grafana/plugins/network-dependency-graph-panel
cmd docker cp $SRC/ $ID:/var/lib/grafana/plugins/network-dependency-graph-panel
cmd docker exec --user=root -it $ID rm -rf /var/lib/grafana/plugins/network-dependency-graph-panel/node_modules
cmd docker exec --user=root -it $ID chown -R grafana:grafana /var/lib/grafana/plugins/network-dependency-graph-panel
cmd docker restart $ID