-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_setup.sh
executable file
·57 lines (39 loc) · 1.06 KB
/
docker_setup.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
#!/bin/bash
__logout_msg=
function ensure_docker() {
[[ $DEBUG -eq 1 ]] && set -x
which docker &>/dev/null || {
curl -o /tmp/docker.install -sSL https://get.docker.com
sudo sh /tmp/docker.install
}
}
function configure_docker() {
[[ $DEBUG -eq 1 ]] && set -x
id -nG pi | grep -q docker || {
sudo usermod -aG docker pi
sudo systemctl enable docker
__logout_msg="
You must logout and login again for environment changes to take effect"
}
}
function start_docker() {
[[ $DEBUG -eq 1 ]] && set -x
sudo systemctl start docker
}
### Process cmdline options
DEBUG=0
while getopts ":d" opt; do
case $opt in
d) DEBUG=1 ;;
esac
done
[[ $DEBUG -eq 1 ]] && set -x
### Source common functions
fn="$(readlink -e ${BASH_SOURCE[$i]%/*})"/bash.common
[[ -r $fn ]] || { echo "Cant access file '$fn'" 1>&2; exit 1
}
source $fn
ensure_docker || die "Failed at: ensure_docker"
configure_docker || die "Failed at: configure_docker"
start_docker || die "Failed at: start_docker"
echo "$__logout_msg"