forked from ClusterHQ/unofficial-flocker-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go.sh
executable file
·107 lines (101 loc) · 4.84 KB
/
go.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
do_install() {
IMAGE="clusterhq/uft:latest"
for CMD in flockerctl flocker-ca flocker-deploy flocker-config flocker-install flocker-plugin-install flocker-sample-files flocker-tutorial flocker-volumes flocker-get-nodes flocker-destroy-nodes volume-hub-agents-install; do
if [ "$CMD" = "flockerctl" ] || [ "$CMD" = "volume-hub-agents-install" ]; then
PREFIX=""
else
PREFIX="uft-"
fi
cat <<EOF |sudo tee /usr/local/bin/${PREFIX}${CMD} >/dev/null
#!/bin/sh
if docker version >/dev/null 2>&1; then
SUDO_PREFIX=""
elif sudo docker version >/dev/null 2>&1; then
SUDO_PREFIX="sudo "
else
echo "==========================================================================="
echo "Unable to reach docker daemon with or without sudo. Please check that"
echo "docker is running and that DOCKER_HOST is set correctly."
echo
echo "If you use docker-machine (e.g. as part of docker toolbox) then"
echo "'eval \\\$(docker-machine env default)' or similar may help."
echo
echo "In that case, also make sure your docker machine is running, using e.g."
echo "'docker-machine start default'."
echo "==========================================================================="
exit 1
fi
if [ ! "\$IGNORE_NETWORK_CHECK" = "1" ]; then
if ! \$SUDO_PREFIX docker run gliderlabs/alpine wget -q -O /dev/null -T 5 http://check.clusterhq.com/?source=uft
then
echo "==========================================================================="
echo "Unable to establish network connectivity from inside a container."
echo
echo "If you see an error message above, that may give you a clue how to fix it."
echo
echo "If you run docker in a VM, restarting the VM often helps, especially if"
echo "you have changed network (and/or DNS servers) since starting the VM."
echo
echo "If you are using docker-machine (e.g. as part of docker toolbox), you can"
echo "run the following command (or similar) to do that:"
echo
echo " docker-machine restart default && eval \\\$(docker-machine env default)"
echo
echo "To ignore this check, and proceed anyway (e.g. if you know you are offline)"
echo "set IGNORE_NETWORK_CHECK=1"
echo "==========================================================================="
exit 1
fi
fi
\$SUDO_PREFIX docker run -ti --rm -e EARLY_DOCKER="\${EARLY_DOCKER}" -e TOKEN="\${TOKEN}" -e CUSTOM_REPO=\${CUSTOM_REPO} -e FORCE_DESTROY=\${FORCE_DESTROY} -e CONTAINERIZED=1 -v /:/host -v \$PWD:/pwd:z $IMAGE $CMD "\$@"
EOF
sudo chmod +x /usr/local/bin/${PREFIX}${CMD}
echo "Installed /usr/local/bin/${PREFIX}${CMD}"
done
if docker version >/dev/null 2>&1; then
SUDO_PREFIX=""
elif sudo docker version >/dev/null 2>&1; then
SUDO_PREFIX="sudo "
else
echo "==========================================================================="
echo "Unable to reach docker daemon with or without sudo. Please check that"
echo "docker is running and that DOCKER_HOST is set correctly."
echo
echo "If you use docker-machine (e.g. as part of docker toolbox) then"
echo "'eval \$(docker-machine env default)' or similar may help."
echo
echo "In that case, also make sure your docker machine is running, using e.g."
echo "'docker-machine start default'."
echo "==========================================================================="
exit 1
fi
echo "Verifying internet connectivity inside container..."
if [ ! "$IGNORE_NETWORK_CHECK" = "1" ]; then
if ! $SUDO_PREFIX docker run gliderlabs/alpine wget -q -O /dev/null -T 5 http://check.clusterhq.com/?source=uft-install
then
echo "==========================================================================="
echo "Unable to establish network connectivity from inside a container."
echo
echo "If you see an error message above, that may give you a clue how to fix it."
echo
echo "If you run docker in a VM, restarting the VM often helps, especially if"
echo "you have changed network (and/or DNS servers) since starting the VM."
echo
echo "If you are using docker-machine (e.g. as part of docker toolbox), you can"
echo "run the following command (or similar) to do that:"
echo
echo " docker-machine restart default && eval \$(docker-machine env default)"
echo
echo "To ignore this check, and proceed anyway (e.g. if you know you are offline)"
echo "set IGNORE_NETWORK_CHECK=1"
echo "==========================================================================="
exit 1
fi
fi
echo "Pulling Docker image for Flocker installer..."
$SUDO_PREFIX docker pull $IMAGE
}
# wrapped up in a function so that we have some protection against only getting
# half the file during "curl | sh"
do_install