-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·159 lines (141 loc) · 4.13 KB
/
install
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bash
set -eo pipefail; [[ -n "$PLUSHU_TRACE" ]] && set -x
echo_install_information () {
local distro=""
if [[ -f /etc/os-release ]]; then
distro=`sed -n 's/^ID=\(.*\)$/\1/p' /etc/os-release`
fi
case "$distro" in
arch)
cat <<"EOF"
To install Docker on Arch Linux, run
# pacman -S docker
See http://docs.docker.com/installation/archlinux/ for more info.
EOF
;;
ubuntu)
cat <<"EOF"
To install Docker on Ubuntu, run
$ curl -s https://get.docker.io/ubuntu/ | sudo sh
See http://docs.docker.com/installation/ubuntulinux/ for more info.
EOF
;;
*)
cat <<"EOF"
Look up how to install Docker on your system:
http://docs.docker.com/installation/
EOF
;;
esac
}
check_docker_run_status () {
if command -v systemctl >/dev/null 2>&1; then
if systemctl -q is-enabled docker.service; then
echo "Docker is enabled via systemctl... good."
else
echo "Docker does not appear to be enabled. Enable it with:"
echo
echo "# systemctl enable docker.service"
echo
fi
if systemctl -q is-active docker.service; then
echo "Docker is currently running... good."
else
echo "Docker does not appear to be currently running. Start it with:"
echo
echo "# systemctl start docker.service"
echo
fi
else
if pgrep -x docker >/dev/null 2>&1; then
echo "Docker appears to be running... good."
else
echo "Docker doesn't appear to be running."
echo "You should start it with something like:"
echo
echo "# service start docker"
echo
fi
echo "Make sure Docker is set to run automatically at startup."
fi
}
add_plushu_user_to_docker_group () {
if id -Gn "$PLUSHU_USER" | grep -q '\bdocker\b'; then
echo "plushu is a member of the docker group... good."
else
if [[ "$EUID" == 0 ]]; then
echo "Adding plushu to the docker group..."
usermod -aG docker "$PLUSHU_USER"
else
echo "plushu is not a member of the docker group."
echo "To create it, reinstall this plugin as root, or run:"
echo
echo "# groupadd docker"
fi
fi
}
setup_docker_for_plushu () {
if egrep -i "^docker" /etc/group; then
echo "docker group already exists... good."
add_plushu_user_to_docker_group
else
if [[ "$EUID" == 0 ]]; then
echo "docker group does not already exist, creating it..."
groupadd docker
add_plushu_user_to_docker_group
else
cat <<EOF
The \"docker\" user group does not already exist.
To create it, reinstall this plugin as root, or run:
# groupadd docker
After you have created the docker group, the plushu user will need to be added
to it for access to Docker. Either re-install the plugin as root, or add
plushu to the group with:
# usermod -aG docker plushu
EOF
fi
fi
check_docker_run_status
}
check_for_docker_dot_io () {
# If docker.io is present (the name it's installed to for Ubuntu)
if [[ -x /usr/bin/docker.io ]]; then
cat <<"EOF"
The Docker we want appears to be at /usr/bin/docker.io rather than somewhere
where it can be called as "docker".
EOF
if [[ "$EUID" == 0 ]]; then
echo "Creating symlink for plushu..."
ln -sf /usr/bin/docker.io "$PLUSHU_ROOT/bin/docker"
else
cat <<EOF
You can fix this system-wide by running:
# ln -sf /usr/bin/docker.io /usr/local/bin/docker
Or, if you re-run this script as root, docker will be linked just for plushu,
as $PLUSHU_ROOT/bin/docker.
EOF
fi
else
echo "Docker does not appear to be installed."
echo_install_information
fi
}
# if Docker is present
if command -v docker >/dev/null 2>&1; then
# If it exits 0 when run as `docker -v`
if docker -v >/dev/null 2>&1; then
echo "Docker appears to be installed... good."
setup_docker_for_plushu
# If it exits non-zero when run as `docker -v` (the tray app that goes by
# "Docker" exits with a status of 2)
else
cat <<"EOF"
It looks like `docker` on your system refers to the system tray application
known as Docker (http://icculus.org/openbox/2/docker/), rather than the
Docker we want (https://www.docker.com/).
EOF
check_for_docker_dot_io
fi
else
check_for_docker_dot_io
fi