forked from feedvisor/etcd-ecs-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
34 lines (31 loc) · 1.22 KB
/
entrypoint.sh
File metadata and controls
34 lines (31 loc) · 1.22 KB
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
#!/bin/bash
IP_V4=$(curl http://169.254.169.254/latest/meta-data/local-ipv4);
INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id);
PUBLIC_V4=$(curl http://169.254.169.254/latest/meta-data/public-ipv4);
#Run instructions:
# docker run -d -e ETCD_TOKEN=<your token> <docker image name>"
# More instructions
# https://coreos.com/os/docs/latest/cluster-discovery.html"
#If ETCD_TOKEN is not specified we run it as a private discovery cluster
if [ -z $ETCD_TOKEN ]
then
cd /opt/etcd
./etcd \
-name etcd0 \
-advertise-client-urls http://$PUBLIC_V4:2379,http://$PUBLIC_V4:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://$PUBLIC_V4:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster etcd0=http://$PUBLIC_V4:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster-state new
else
cd /opt/etcd
./etcd \
-name $INSTANCE_ID \
-advertise-client-urls http://$IP_V4:2379,http://$IP_V4:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://$IP_V4:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-discovery https://discovery.etcd.io/$ETCD_TOKEN
fi