-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy_docker.sh
executable file
·96 lines (83 loc) · 2.71 KB
/
deploy_docker.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
#!/bin/bash
#===============================================================================
#
# FILE: deploy_docker.sh
#
# USAGE: ./deploy_docker.sh -i $ipAddress -h $hostname
#
# DESCRIPTION: Install Docker on CentOS, optionally, this can
# set a hostname in /etc/hosts
#
# OPTIONS: -i the IP address
# -h the hostname
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Matt Coffey (),
# COMPANY:
# VERSION: 1.0
# CREATED: 02/06/14 20:10:59 GMT
# REVISION: ---
#===============================================================================
echo "Running deploy_docker.sh"
if [[ -f /etc/provisioned ]];
then
echo "Provisioned on:"
echo "cat $(/etc/provisioned)"
echo "Skipping deploy_docker.sh..."
exit 0
fi
echo "Provisioned on $(date)" > /etc/provisioned
while getopts i:h: option
do
case "${option}"
in
i) IP=$OPTARG;;
h) HOST=$OPTARG;;
esac
done
# Add this hostname to /etc/hosts if IP and hostname have been specified
if [[ ! -z "$IP" && ! -z "$HOST" ]];
then
echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\n" > /etc/hosts
echo "::1 localhost localhost.localdomain localhost6 localhost6.localdomain6\n" >> /etc/hosts
echo "$IP $HOST $HOST" >> /etc/hosts
fi
echo "Installing wget..."
yum install wget <<EOF
y
EOF
echo "Installing Docker"
yum install docker-io <<EOF
y
EOF
echo 'other_args="-H tcp://0.0.0.0:4243"' >> /etc/sysconfig/docker
service docker restart
echo 'export DOCKER_HOST=tcp://0.0.0.0:4243' >> /home/vagrant/.bashrc
echo 'alias docker="sudo docker -H $DOCKER_HOST"' >> /home/vagrant/.bashrc
echo "Starting Docker Daemon"
service docker start
chkconfig docker on
# Invoke docker to indicate whether this script was successful
docker -v >/dev/null
# Check whether the docker command executed successfully
if [[ $? -ne 0 ]];
then
echo "Docker failed to install"
exit 1
fi
echo " ## ." > /etc/motd
echo " ## ## ## ==" >> /etc/motd
echo " ## ## ## ## ===" >> /etc/motd
echo ' /""""""""""""""""\___/ ===' >> /etc/motd
echo " ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~" >> /etc/motd
echo " \______ o __/" >> /etc/motd
echo " \ \ __/" >> /etc/motd
echo " \____\______/" >> /etc/motd
echo "" >> /etc/motd
echo " | |" >> /etc/motd
echo " __ | __ __ | _ __ _" >> /etc/motd
echo " / \| / \ / |/ / _\ |" >> /etc/motd
echo " \__/| \__/ \__ |\_ \__ |" >> /etc/motd
echo "Docker installed successfully"
exit 0