-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgo.sh
executable file
·137 lines (129 loc) · 5.75 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
do_install() {
IMAGE="clusterhq/uft:latest"
DEPRECATION_WARNING=$(cat <<EOF
deprecated in Flocker 1.14.0 and will be removed in future versions of Flocker.
Use the official installation methods and tools instead.
See https://docs.clusterhq.com.
EOF
)
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=""
DEPRECATED="FALSE"
else
PREFIX="uft-"
# Deprecate all the uft-* tools.
DEPRECATED="TRUE"
fi
cat <<EOF |sudo tee /usr/local/bin/${PREFIX}${CMD} >/dev/null
#!/bin/sh
DEPRECATED="${DEPRECATED}"
DEPRECATION_WARNING=\$(cat <<END_WARNING
${DEPRECATION_WARNING}
END_WARNING
)
if [ "\${DEPRECATED}" = "TRUE" ]; then
echo "WARNING: ${PREFIX}${CMD} was \${DEPRECATION_WARNING}" >&2
echo "" >&2
fi
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 --rm gliderlabs/alpine wget -q -O /dev/null -T 5 http://check.clusterhq.com/uft.txt
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 FLOCKER_CERTS_PATH="\${FLOCKER_CERTS_PATH}" -e FLOCKER_USER="\${FLOCKER_USER}" -e FLOCKER_CONTROL_SERVICE="\${FLOCKER_CONTROL_SERVICE}" -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}
if [ "${DEPRECATED}" = "TRUE" ]; then
EXTRA=" (deprecated)"
else
EXTRA=""
fi
echo "Installed /usr/local/bin/${PREFIX}${CMD}${EXTRA}"
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 --rm gliderlabs/alpine wget -q -O /dev/null -T 5 http://check.clusterhq.com/uft-install.txt
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
if [ -n "${DEPRECATION_WARNING}" ]; then
echo "" >&2
echo "WARNING: Some of these commands were ${DEPRECATION_WARNING}" >&2
fi
echo ""
}
# wrapped up in a function so that we have some protection against only getting
# half the file during "curl | sh"
do_install