-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_docker
executable file
·148 lines (128 loc) · 5.83 KB
/
install_docker
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
#!/usr/bin/env bash
##
# Acuparse Docker Installation Script
# @copyright Copyright (C) 2015-2022 Maxwell Power
# @author Maxwell Power <[email protected]>
# @license MIT
#
# 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.
##
REPO='master'
COMPOSE_VERSION='2.10.2'
DIST=$(cat /etc/*release | grep '^ID=' | awk -F= '{ print $2 }')
# Set Text Colours
GREEN_TEXT='\033[0;32m' BOLD_GREEN_TEXT='\033[1;32m' UNDERLINE_GREEN_TEXT='\033[4;32m' HIGHLIGHT_GREEN_TEXT='\033[7;32m' RED_TEXT='\033[0;31m' BOLD_RED_TEXT='\033[1;31m' UNDERLINE_RED_TEXT='\033[4;31m' BLUE_TEXT='\033[0;34m' BOLD_BLUE_TEXT='\033[1;34m' UNDERLINE_BLUE_TEXT='\033[4;34m' YELLOW_TEXT='\033[0;33m' BOLD_YELLOW_TEXT='\033[1;33m' UNDERLINE_YELLOW_TEXT='\033[4;33m' PURPLE_TEXT='\033[0;35m' BOLD_PURPLE_TEXT='\033[1;35m' UNDERLINE_PURPLE_TEXT='\033[4;35m' CYAN_TEXT="\033[0;36m" BOLD_CYAN_TEXT="\033[1;36m" UNDERLINE_CYAN_TEXT="\033[4;36m" RESET_TEXT='\033[0m'
function _install_docker() {
printf "${GREEN_TEXT}""Installing Docker""${RESET_TEXT}""\n"
if [[ ("$DIST" == "debian") || ("$DIST" == "raspbian") ]]; then
apt-get update
apt-get install -yqq \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -yqq
elif [[ ("$DIST" == "ubuntu") ]]; then
apt-get update
apt-get install -yqq \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -yqq
fi
}
function _install_docker_compose() {
printf "${GREEN_TEXT}""Installing Docker Compose""${RESET_TEXT}""\n"
if [[ ("$DIST" == "debian") || ("$DIST" == "ubuntu") ]]; then
curl -L "https://github.com/docker/compose/releases/download/v$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
elif [[ ("$DIST" == "raspbian") ]]; then
apt-get install libffi-dev libssl-dev python3-dev python3 python3-pip -yqq
pip3 install docker-compose -q
fi
}
function _load_docker_compose_config() {
printf "${GREEN_TEXT}""Downloading Docker Compose Configuration""${RESET_TEXT}""\n"
mkdir -p /opt/acuparse
cd /opt/acuparse || exit 1
curl -s -O https://gitlab.com/acuparse/installer/raw/"$REPO"/docker/docker-compose.yml
curl -s -O https://gitlab.com/acuparse/installer/raw/"$REPO"/docker/acuparse.env
curl -s -O https://gitlab.com/acuparse/installer/raw/"$REPO"/docker/acuparse
mv acuparse /usr/local/bin
chmod +x /usr/local/bin/acuparse
}
function _get_environment() {
printf "${GREEN_TEXT}""Configure Your Environment""${RESET_TEXT}""\n"
printf "${BLUE_TEXT}""Set MySQL Root Password, followed by [ENTER]:""${RESET_TEXT}""\n"
read -r MYSQL_ROOT_PASSWORD
printf "${BLUE_TEXT}""Set Acuparse DB Password, followed by [ENTER]:""${RESET_TEXT}""\n"
read -r MYSQL_PASSWORD
printf "${BLUE_TEXT}""Set Timezone, followed by [ENTER]:\n""${RED_TEXT}""Example: America/Denver""${RESET_TEXT}""\n"
read -r TZ
}
function _update_environment() {
sed -i "s/MYSQL_ROOT_PASSWORD=STRONG_PASSWORD/MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD/" acuparse.env
sed -i "s/MYSQL_PASSWORD=STRONG_PASSWORD/MYSQL_PASSWORD=$MYSQL_PASSWORD/" acuparse.env
sed -i "s|TZ=Etc/UTC|TZ=$TZ|" acuparse.env
}
function _usage_details() {
printf "${UNDERLINE_YELLOW_TEXT}""To enable Lets Encrypt, edit /opt/acuparse/acuparse.env""${RESET_TEXT}""\n\n"
printf "${YELLOW_TEXT}""Start Acuparse by running""${RESET_TEXT}""\n"
printf "${BOLD_RED_TEXT}""sudo acuparse start""${RESET_TEXT}""\n\n"
printf "${YELLOW_TEXT}""To run acupase without root/sudo, add your user account to the Docker group""${RESET_TEXT}""\n"
printf "${BOLD_RED_TEXT}""sudo usermod -a -G docker %s""${RESET_TEXT}""\n\n" "$SUDO_USER"
}
#Check for ROOT
if [[ $(id -u) != "0" ]]; then
printf "${RED_TEXT}""ERROR: Installer must be run as root/sudo!""${RESET_TEXT}""\n"
exit 1
fi
printf "${PURPLE_TEXT}""Starting Acuparse Docker Install""${RESET_TEXT}""\n\n"
if [ "$1" == 'full' ]; then
_install_docker
_install_docker_compose
elif [ "$1" == 'compose' ]; then
_install_docker_compose
fi
_load_docker_compose_config
if [ "$2" == 'ci' ]; then
MYSQL_ROOT_PASSWORD="CITEST"
MYSQL_PASSWORD="CITEST"
TZ="America/Denver"
else
_get_environment
fi
_update_environment
printf "${PURPLE_TEXT}""DONE: Acuparse Docker Installation Complete!""${RESET_TEXT}""\n\n"
_usage_details