github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/hack/install.sh (about) 1 #!/bin/sh 2 set -e 3 # 4 # This script is meant for quick & easy install via: 5 # 'curl -sSL https://get.docker.com/ | sh' 6 # or: 7 # 'wget -qO- https://get.docker.com/ | sh' 8 # 9 # 10 # Docker Maintainers: 11 # To update this script on https://get.docker.com, 12 # use hack/release.sh during a normal release, 13 # or the following one-liner for script hotfixes: 14 # s3cmd put --acl-public -P hack/install.sh s3://get.docker.com/index 15 # 16 17 url='https://get.docker.com/' 18 19 command_exists() { 20 command -v "$@" > /dev/null 2>&1 21 } 22 23 echo_docker_as_nonroot() { 24 your_user=your-user 25 [ "$user" != 'root' ] && your_user="$user" 26 # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output 27 cat <<-EOF 28 29 If you would like to use Docker as a non-root user, you should now consider 30 adding your user to the "docker" group with something like: 31 32 sudo usermod -aG docker $your_user 33 34 Remember that you will have to log out and back in for this to take effect! 35 36 EOF 37 } 38 39 do_install() { 40 case "$(uname -m)" in 41 *64) 42 ;; 43 *) 44 cat >&2 <<-'EOF' 45 Error: you are not using a 64bit platform. 46 Docker currently only supports 64bit platforms. 47 EOF 48 exit 1 49 ;; 50 esac 51 52 if command_exists docker || command_exists lxc-docker; then 53 cat >&2 <<-'EOF' 54 Warning: "docker" or "lxc-docker" command appears to already exist. 55 Please ensure that you do not already have docker installed. 56 You may press Ctrl+C now to abort this process and rectify this situation. 57 EOF 58 ( set -x; sleep 20 ) 59 fi 60 61 user="$(id -un 2>/dev/null || true)" 62 63 sh_c='sh -c' 64 if [ "$user" != 'root' ]; then 65 if command_exists sudo; then 66 sh_c='sudo -E sh -c' 67 elif command_exists su; then 68 sh_c='su -c' 69 else 70 cat >&2 <<-'EOF' 71 Error: this installer needs the ability to run commands as root. 72 We are unable to find either "sudo" or "su" available to make this happen. 73 EOF 74 exit 1 75 fi 76 fi 77 78 curl='' 79 if command_exists curl; then 80 curl='curl -sSL' 81 elif command_exists wget; then 82 curl='wget -qO-' 83 elif command_exists busybox && busybox --list-modules | grep -q wget; then 84 curl='busybox wget -qO-' 85 fi 86 87 # perform some very rudimentary platform detection 88 lsb_dist='' 89 if command_exists lsb_release; then 90 lsb_dist="$(lsb_release -si)" 91 fi 92 if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then 93 lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")" 94 fi 95 if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then 96 lsb_dist='debian' 97 fi 98 if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then 99 lsb_dist='fedora' 100 fi 101 if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then 102 lsb_dist="$(. /etc/os-release && echo "$ID")" 103 fi 104 105 lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')" 106 case "$lsb_dist" in 107 amzn|fedora|centos) 108 if [ "$lsb_dist" = 'amzn' ]; then 109 ( 110 set -x 111 $sh_c 'sleep 3; yum -y -q install docker' 112 ) 113 else 114 ( 115 set -x 116 $sh_c 'sleep 3; yum -y -q install docker-io' 117 ) 118 fi 119 if command_exists docker && [ -e /var/run/docker.sock ]; then 120 ( 121 set -x 122 $sh_c 'docker version' 123 ) || true 124 fi 125 echo_docker_as_nonroot 126 exit 0 127 ;; 128 129 ubuntu|debian|linuxmint|'elementary os'|kali) 130 export DEBIAN_FRONTEND=noninteractive 131 132 did_apt_get_update= 133 apt_get_update() { 134 if [ -z "$did_apt_get_update" ]; then 135 ( set -x; $sh_c 'sleep 3; apt-get update' ) 136 did_apt_get_update=1 137 fi 138 } 139 140 # aufs is preferred over devicemapper; try to ensure the driver is available. 141 if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then 142 if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -q '^ii' 2>/dev/null; then 143 kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual" 144 145 apt_get_update 146 ( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true 147 148 if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then 149 echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)' 150 echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!' 151 ( set -x; sleep 10 ) 152 fi 153 else 154 echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual' 155 echo >&2 ' package. We have no AUFS support. Consider installing the packages' 156 echo >&2 ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.' 157 ( set -x; sleep 10 ) 158 fi 159 fi 160 161 # install apparmor utils if they're missing and apparmor is enabled in the kernel 162 # otherwise Docker will fail to start 163 if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then 164 if command -v apparmor_parser &> /dev/null; then 165 echo 'apparmor is enabled in the kernel and apparmor utils were already installed' 166 else 167 echo 'apparmor is enabled in the kernel, but apparmor_parser missing' 168 apt_get_update 169 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' ) 170 fi 171 fi 172 173 if [ ! -e /usr/lib/apt/methods/https ]; then 174 apt_get_update 175 ( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' ) 176 fi 177 if [ -z "$curl" ]; then 178 apt_get_update 179 ( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' ) 180 curl='curl -sSL' 181 fi 182 ( 183 set -x 184 if [ "https://get.docker.com/" = "$url" ]; then 185 $sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9" 186 elif [ "https://test.docker.com/" = "$url" ]; then 187 $sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 740B314AE3941731B942C66ADF4FD13717AAD7D6" 188 else 189 $sh_c "$curl ${url}gpg | apt-key add -" 190 fi 191 $sh_c "echo deb ${url}ubuntu docker main > /etc/apt/sources.list.d/docker.list" 192 $sh_c 'sleep 3; apt-get update; apt-get install -y -q lxc-docker' 193 ) 194 if command_exists docker && [ -e /var/run/docker.sock ]; then 195 ( 196 set -x 197 $sh_c 'docker version' 198 ) || true 199 fi 200 echo_docker_as_nonroot 201 exit 0 202 ;; 203 204 gentoo) 205 if [ "$url" = "https://test.docker.com/" ]; then 206 # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output 207 cat >&2 <<-'EOF' 208 209 You appear to be trying to install the latest nightly build in Gentoo.' 210 The portage tree should contain the latest stable release of Docker, but' 211 if you want something more recent, you can always use the live ebuild' 212 provided in the "docker" overlay available via layman. For more' 213 instructions, please see the following URL:' 214 215 https://github.com/tianon/docker-overlay#using-this-overlay' 216 217 After adding the "docker" overlay, you should be able to:' 218 219 emerge -av =app-emulation/docker-9999' 220 221 EOF 222 exit 1 223 fi 224 225 ( 226 set -x 227 $sh_c 'sleep 3; emerge app-emulation/docker' 228 ) 229 exit 0 230 ;; 231 esac 232 233 # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output 234 cat >&2 <<-'EOF' 235 236 Either your platform is not easily detectable, is not supported by this 237 installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have 238 a package for Docker. Please visit the following URL for more detailed 239 installation instructions: 240 241 https://docs.docker.com/en/latest/installation/ 242 243 EOF 244 exit 1 245 } 246 247 # wrapped up in a function so that we have some protection against only getting 248 # half the file during "curl | sh" 249 do_install