-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrun-flux
executable file
·54 lines (44 loc) · 1.05 KB
/
run-flux
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
#!/bin/bash
set -eo pipefail
DAEMON_IMAGE=weaveworks/fluxd
DEFAULT_ETCD="http://127.0.0.1:2379"
start() {
if [[ -z "$ETCD_ADDRESS" ]]; then
echo "WARNING: no environment entry for ETCD_ADDRESS; using $DEFAULT_ETCD" >&2
ETCD_ADDRESS="$DEFAULT_ETCD"
fi
if [[ -z "$HOST_IP" ]]; then
hostip=$(hostname -i)
echo "WARNING: no environment entry for HOST_IP; used \`hostname -i\` to obtain $hostip" >&2
HOST_IP="$hostip"
fi
export HOST_IP ETCD_ADDRESS
docker run -d --name "fluxd" -e HOST_IP -e ETCD_ADDRESS \
-v "/var/run/docker.sock:/var/run/docker.sock" \
--cap-add=NET_ADMIN --net=host "$DAEMON_IMAGE" \
--listen-prometheus :9000 --advertise-prometheus $HOST_IP:9000
}
stop() {
docker rm -f "fluxd" 2>/dev/null || true
}
usage() {
cat >&2 <<EOF
Usage:
run-flux start|stop|restart
EOF
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage
;;
esac