Newer
Older
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
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# PURPOSE
# This script will setup docker.
# **NOTE** -- This script is used by Eris to provision test box backends which
# we need to be on a specific version of docker. It will likely be unuseful to
# you.
# If you are looking for a quick and easy way to set up eris on a cloud machin
# please see https://github.com/eris-ltd/common/cloud/chains/setup/setup.sh
# If $DOCKER_VERSION is set then the host will use that.
# -----------------------------------------------------------------------------
# LICENSE
# The MIT License (MIT)
# Copyright (c) 2016-Present Eris Industries, Ltd.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
# -----------------------------------------------------------------------------
# REQUIREMENTS
# Ubuntu
# -----------------------------------------------------------------------------
# USAGE
# docker.sh
# -----------------------------------------------------------------------------
# Set defaults
default_docker="1.9.0"
# -----------------------------------------------------------------------------
# Check Ubuntu
#read -p "This script only works on Ubuntu (and does no checking). It may work on some debians. Do you wish to proceed? (y/n) " -n 1 -r
#echo
#if [[ ! $REPLY =~ ^[Yy]$ ]]
#then
# echo "OK. Not doing anything. Bye."
# exit 1
#fi
#echo "You confirmed you are on Ubuntu (or waived compatibility)."
# ----------------------------------------------------------------------------
# Check sudo
if [[ "$USER" != "root" ]]
then
echo "OK. Not doing anything. Bye."
exit 1
fi
echo "Privileges confirmed."
# ----------------------------------------------------------------------------
# Check Docker Version to Install
if [ -z "$DOCKER_VERSION" ]
then
echo "You do not have the \$DOCKER_VERSION set. Trying via hostname (an Eris paradigm)."
export DOCKER_VERSION=$(hostname | cut -d'-' -f4)
if [[ "$DOCKER_VERSION" == `hostname` ]]
then
read -p "I cannot find the Docker Version to Install. You can rerun me with \$DOCKER_VERSION set or use the defaults. Would you like the defaults? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
export DOCKER_VERSION="$default_docker"
fi
fi
fi
echo "Will install Docker for Version: $DOCKER_VERSION"
echo
echo
# ---------------------------------------------------------------------------
# Install Docker Version
echo
wget -qO- https://get.docker.io/gpg | apt-key add -
sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
apt-get update -qq
apt-get install -qqy docker-engine
service docker stop
docker_place=$(which docker)
rm "$docker_place"
curl -sSL --ssl-req -o "$docker_place" https://get.docker.com/builds/Linux/x86_64/docker-$DOCKER_VERSION
chmod 755 "$docker_place"
echo
echo "Docker installed"
# ---------------------------------------------------------------------------
# Restart Docker
echo "Restarting Newly Installed Docker"
echo
service docker start
sleep 3 # boot time
# ---------------------------------------------------------------------------
# Check User Needs to be Added to Docker group
echo
echo
usermod -a -G docker $USER
# ---------------------------------------------------------------------------
# Cleanup
echo
echo
echo "All set"
echo
echo