-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·49 lines (46 loc) · 1.5 KB
/
init.sh
File metadata and controls
executable file
·49 lines (46 loc) · 1.5 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
set -e
source /etc/pidalio.env
/opt/pidalio/kube/kubelet/scripts/download-components.sh
/opt/pidalio/kube/kubelet/scripts/prepare-units.sh
if [[ "${CEPH}" == "True" ]]
then
/opt/pidalio/kube/kubelet/scripts/ceph/install-ceph-tools.sh
docker pull ceph/base
fi
docker pull cedbossneo/docker-etcd-rclone:v1
export DOCKER_HOST=unix:///var/run/weave/weave.sock
function handleExistingEtcd {
EXISTING_ETCD=$(/opt/bin/weave dns-lookup etcd)
echo "Testing $EXISTING_ETCD"
curl -s -m 1 http://${EXISTING_ETCD}:2379/v2/stats/self
if [ $? -eq 0 ]
then
echo "Etcd $EXISTING_ETCD alive";
else
echo "Etcd $EXISTING_ETCD did not come up...exiting"
exit 1
fi
docker run --rm --name=etcd-proxy -p 2379:2379 -p 2380:2380 -p 4001:4001 cedbossneo/docker-etcd-rclone /proxy.sh ${EXISTING_ETCD}
}
function handleNonExistingEtcd {
SLEEP_TIME=$(expr $RANDOM % 50)
echo "Sleeping $SLEEP_TIME seconds"
sleep ${SLEEP_TIME}
EXISTING_ETCD=$(/opt/bin/weave dns-lookup etcd)
echo "Existing ETCD: $EXISTING_ETCD"
if [[ "$EXISTING_ETCD" == "" ]]
then
docker run -e TOKEN=${PIDALIO_TOKEN} -v /etc/pidalio.etcd.rclone.conf:/root/.rclone.conf --rm --name=etcd -p 2379:2379 -p 2380:2380 -p 4001:4001 cedbossneo/docker-etcd-rclone
else
handleExistingEtcd
fi
}
EXISTING_ETCD=$(/opt/bin/weave dns-lookup etcd)
echo "Existing ETCD: $EXISTING_ETCD"
if [[ "$EXISTING_ETCD" == "" ]]
then
handleNonExistingEtcd
else
handleExistingEtcd
fi