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