1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Wrap installer in a function

This will assure that the install script will not
begin executing until after it has been downloaded should
it be utilized in a 'curl | bash' workflow.

Signed-off-by: Eric Windisch <eric@windisch.us>
This commit is contained in:
Eric Windisch 2015-04-09 13:55:26 -04:00
parent 26e83832c7
commit fa961ce046

View file

@ -20,7 +20,8 @@ command_exists() {
command -v "$@" > /dev/null 2>&1
}
case "$(uname -m)" in
do_docker_install() {
case "$(uname -m)" in
*64)
;;
*)
@ -28,19 +29,19 @@ case "$(uname -m)" in
echo >&2 'Docker currently only supports 64bit platforms.'
exit 1
;;
esac
esac
if command_exists docker || command_exists lxc-docker; then
if command_exists docker || command_exists lxc-docker; then
echo >&2 'Warning: "docker" or "lxc-docker" command appears to already exist.'
echo >&2 'Please ensure that you do not already have docker installed.'
echo >&2 'You may press Ctrl+C now to abort this process and rectify this situation.'
( set -x; sleep 20 )
fi
fi
user="$(id -un 2>/dev/null || true)"
user="$(id -un 2>/dev/null || true)"
sh_c='sh -c'
if [ "$user" != 'root' ]; then
sh_c='sh -c'
if [ "$user" != 'root' ]; then
if command_exists sudo; then
sh_c='sudo -E sh -c'
elif command_exists su; then
@ -50,37 +51,37 @@ if [ "$user" != 'root' ]; then
echo >&2 'We are unable to find either "sudo" or "su" available to make this happen.'
exit 1
fi
fi
fi
curl=''
if command_exists curl; then
curl=''
if command_exists curl; then
curl='curl -sSL'
elif command_exists wget; then
elif command_exists wget; then
curl='wget -qO-'
elif command_exists busybox && busybox --list-modules | grep -q wget; then
elif command_exists busybox && busybox --list-modules | grep -q wget; then
curl='busybox wget -qO-'
fi
fi
# perform some very rudimentary platform detection
lsb_dist=''
if command_exists lsb_release; then
# perform some very rudimentary platform detection
lsb_dist=''
if command_exists lsb_release; then
lsb_dist="$(lsb_release -si)"
fi
if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
fi
if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
fi
if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
fi
if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
lsb_dist='debian'
fi
if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then
fi
if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then
lsb_dist='fedora'
fi
if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
fi
if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
fi
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
case "$lsb_dist" in
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
case "$lsb_dist" in
amzn|fedora|centos)
if [ "$lsb_dist" = 'amzn' ]; then
(
@ -217,16 +218,18 @@ case "$lsb_dist" in
)
exit 0
;;
esac
esac
cat >&2 <<'EOF'
echo >&2
echo >&2 'Either your platform is not easily detectable, is not supported by this'
echo >&2 'installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have'
echo >&2 'a package for Docker. Please visit the following URL for more detailed'
echo >&2 'installation instructions:'
echo >&2
echo >&2 ' https://docs.docker.com/en/latest/installation/'
echo >&2
exit 1
}
Either your platform is not easily detectable, is not supported by this
installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have
a package for Docker. Please visit the following URL for more detailed
installation instructions:
https://docs.docker.com/en/latest/installation/
EOF
do_docker_install
exit 1