-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·487 lines (440 loc) · 19.7 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
#!/usr/bin/env bash
SCRIPT_VERSION='2.12'
##
# Acuparse Installation Script
# @copyright Copyright (C) 2015-2022 Maxwell Power
# @author Maxwell Power <max@acuparse.com>
# @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.
##
function _usage() {
printf "Usage: [-b Branch] [-s Silent] [-l LE] [-p DB PASS] [-t Timezone] [-e EXIM] [-d Debug]\n\n"
printf "Default is interactive install. For scripted install, use [-s (Optional: -b branch -t \"region/timezone\" -p \"root,acuparse\" -l \"FQDN,EMAIL,REDIRECT(y/n),WWW(y/n)\" -e -a)]\n"
exit 0
}
# Default Values
SILENT=false
GIT_BRANCH="stable"
ACUPARSE_DB_PASSWORD=$(
head /dev/urandom | tr -dc A-Za-z0-9 | head -c 15
echo ''
)
SQL_PW_SET=false
while getopts ":db::sep::l::t::" opt; do
case ${opt} in
d)
set -x
;;
b)
GIT_BRANCH=${OPTARG}
;;
s)
SILENT=true
export DEBIAN_FRONTEND=noninteractive
;;
e)
EXIM_ENABLED="y"
;;
p)
set -f
IFS=,
DBPW_ARRAY=("$OPTARG")
MYSQL_ROOT_PASSWORD=${DBPW_ARRAY[0]}
ACUPARSE_DB_PASSWORD=${DBPW_ARRAY[1]}
SQL_PW_SET=true
set +f
IFS=
;;
l)
set -f
IFS=,
LE_SSL_ENABLED="y"
LE_ARRAY=("$OPTARG")
LE_FQDN=${LE_ARRAY[0]}
LE_EMAIL=${LE_ARRAY[1]}
LE_REDIRECT_ENABLED=${LE_ARRAY[2]}
LE_SECURE_WWW=${LE_ARRAY[3]}
set +f
IFS=,
;;
t)
TIMEZONE=${OPTARG}
TZ_OPT_SET=true
;;
\?)
_usage
exit 0
;;
esac
done
# 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'
# Script Variables
SYS_IP=$(hostname -i)
SYS_FQDN=$(hostname -A)
DIST=$(cat /etc/*release | grep '^ID=' | awk -F= '{ print $2 }')
DEB_VERSION=$(cat /etc/*release | grep '^VERSION_ID=' | awk -F= '{ print $2 }')
UBU_VERSION=$(cat /etc/*release | grep '^DISTRIB_RELEASE=' | awk -F= '{ print $2 }')
function _run_acuparse_install() {
git init /opt/acuparse
cd /opt/acuparse || exit 12
git remote add -f origin https://github.com/acuparse/acuparse.git
if [[ "$GIT_BRANCH" == "stable" ]]; then
git branch --set-upstream-to=origin/stable stable
git checkout stable
else
git branch --set-upstream-to=origin/stable stable
git branch --set-upstream-to=origin/"${GIT_BRANCH}" "${GIT_BRANCH}"
git checkout "${GIT_BRANCH}"
fi
git pull
chown -R www-data:www-data /opt/acuparse/src/pub
chown -R www-data:www-data /opt/acuparse/src/usr
}
function _run_exim_install() {
apt-get install exim4 -y
printf "Launch exim configuration\n"
if [[ "$SILENT" == false ]]; then
dpkg-reconfigure exim4-config
fi
}
function _run_apache_setup() {
a2dissite 000-default.conf >/dev/null 2>&1
rm /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/default-ssl.conf
cp /opt/acuparse/config/acuparse.conf /etc/apache2/sites-available/
cp /opt/acuparse/config/acuparse-ssl.conf /etc/apache2/sites-available/
a2enmod rewrite >/dev/null 2>&1
a2enmod ssl >/dev/null 2>&1
a2ensite acuparse.conf >/dev/null 2>&1
a2ensite acuparse-ssl.conf >/dev/null 2>&1
}
function _install_le_cert() {
if [[ ("$LE_SECURE_WWW" == "y") || ("$LE_SECURE_WWW" == "Y") ]]; then
LE_SECURE_DOMAINS=(-d "$LE_FQDN" -d www."$LE_FQDN")
sed -i "s/#ServerName/ServerName ${LE_FQDN}\n ServerAlias www.${LE_FQDN}/g" /etc/apache2/sites-available/acuparse-ssl.conf
else
LE_SECURE_DOMAINS=(-d "$LE_FQDN")
sed -i "s/#ServerName/ServerName ${LE_FQDN}/g" /etc/apache2/sites-available/acuparse-ssl.conf
fi
if [[ ("$LE_REDIRECT_ENABLED" == "y") || ("$LE_REDIRECT_ENABLED" == "Y") ]]; then
LE_REDIRECT="redirect"
else
LE_REDIRECT="no-redirect"
fi
if [[ ("$DIST" == "ubuntu") && ("$UBU_VERSION" == "22.04") ]]; then
printf "${YELLOW_TEXT}""UBUNTU Jammy (22.04) DETECTED!""${RESET_TEXT}""\n"
apt-get install software-properties-common python3-certbot-apache -y
elif [[ ("$DIST" == "ubuntu") && ("$UBU_VERSION" == "20.04") ]]; then
printf "${YELLOW_TEXT}""UBUNTU Focal (20.04) DETECTED! Using certbot PPA""${RESET_TEXT}""\n"
apt-get install software-properties-common -y
add-apt-repository ppa:certbot/certbot -y
apt-get update >/dev/null 2>&1
apt-get install python3-certbot-apache -y
elif [[ ("$DIST" == "debian") && ("$DEB_VERSION" == "\"11\"") ]]; then
printf "${YELLOW_TEXT}""DEBIAN BULLSEYE DETECTED! Using Python 3""${RESET_TEXT}""\n"
apt-get install python3-certbot-apache -y
else
apt-get install python-certbot-apache -y
fi
systemctl stop apache2 || service apache2 stop
if [[ "$GIT_BRANCH" != "stable" ]]; then
printf "Requesting cert from STAGING server\n"
certbot -n --authenticator standalone --installer apache --agree-tos --"${LE_REDIRECT}" --email "${LE_EMAIL}" "${LE_SECURE_DOMAINS[@]}" --staging
else
printf "Requesting cert from PRODUCTION server\n"
certbot -n --authenticator standalone --installer apache --agree-tos --"${LE_REDIRECT}" --email "${LE_EMAIL}" "${LE_SECURE_DOMAINS[@]}"
fi
systemctl start apache2 || service apache2 start
}
function __save_database_credentials() {
cat >~/.acuparse_db <<EOF
ACUPARSE_DB_PASSWORD=${ACUPARSE_DB_PASSWORD}
EOF
}
function _run_database_install() {
if [[ ("$DIST" == "ubuntu") ]]; then
chmod go+rx /var/run/mysqld
usermod -d /var/lib/mysql/ mysql
fi
systemctl restart mysql || systemctl restart mariadb || service mysql restart || service mariadb restart || exit 1
if [[ "$SQL_PW_SET" == false ]]; then
__save_database_credentials
fi
mysql -uroot -e "DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DROP DATABASE IF EXISTS test; DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'; FLUSH PRIVILEGES;"
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS acuparse; CREATE USER 'acuparse' IDENTIFIED BY '$ACUPARSE_DB_PASSWORD'; GRANT ALL ON acuparse.* TO 'acuparse'; GRANT EVENT ON acuparse.* TO 'acuparse'; GRANT RELOAD ON *.* TO 'acuparse'; GRANT SUPER ON *.* TO 'acuparse'; FLUSH PRIVILEGES;"
systemctl restart mysql || systemctl restart mariadb || service mysql restart || service mariadb restart || exit 1
}
function _run_timezone_set() {
if [[ "$SILENT" == true ]]; then
rm /etc/localtime
rm /etc/timezone
ln -s ../usr/share/zoneinfo/"${TIMEZONE}" /etc/localtime
echo "${TIMEZONE}" >/etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata
export TZ="${TIMEZONE}"
else
printf "\n""${CYAN_TEXT}""Configuring your system timezone.""${RESET_TEXT}""\n"
printf "${RED_TEXT}""When ready, Press [ENTER] to continue""${RESET_TEXT}""\n"
read -r READY
dpkg-reconfigure tzdata
fi
systemctl restart rsyslog || service rsyslog restart
systemctl enable systemd-timesyncd || true
systemctl start systemd-timesyncd || true
timedatectl set-ntp on || true
}
function _openSSL() {
echo "Configuring OpenSSL for TLS v1.1 support"
if [[ "$UBUNTU_JAMMY" == true ]]; then
sed -i 's/SECLEVEL=2/SECLEVEL=0/' /etc/ssl/openssl.cnf
sed -i 's/SECLEVEL=1/SECLEVEL=0/' /etc/apache2/sites-available/acuparse-ssl.conf
printf "MinProtocol = TLSv1.1\n" >>/etc/ssl/openssl.cnf
elif [[ "$UBUNTU_FOCAL" == true ]]; then
sed -i '1s/^/openssl_conf = default_conf\n/' /etc/ssl/openssl.cnf
printf "[ default_conf ]\nssl_conf = ssl_sect\n\n[ ssl_sect ]\nsystem_default = system_default_sect\n\n[ system_default_sect ]\nMinProtocol = TLSv1.1\nCipherString = DEFAULT@SECLEVEL=1\n" >>/etc/ssl/openssl.cnf
else
sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1.1/' /etc/ssl/openssl.cnf
sed -i 's/SECLEVEL=2/SECLEVEL=1/' /etc/ssl/openssl.cnf
fi
echo "Done: OpenSSL Config"
}
function _cleanup() {
exit_code="$?"
if [[ "$exit_code" == 0 ]]; then
# Install Complete
printf "${PURPLE_TEXT}""DONE: Acuparse Installation Complete!""${RESET_TEXT}""\n\n"
SYS_WAN=$(dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}')
printf "${YELLOW_TEXT}""Connect to your IP/Hostname with a browser to continue.""${RESET_TEXT}""\n\n"
printf "SYSTEM Hostname: ""${BOLD_BLUE_TEXT}""${SYS_FQDN}""${RESET_TEXT}""\n"
printf "SYSTEM IP: ""${BOLD_BLUE_TEXT}""${SYS_IP}""${RESET_TEXT}""\n"
printf "EXTERNAL IP: ""${UNDERLINE_GREEN_TEXT}""${SYS_WAN}""${RESET_TEXT}""\n"
export MYSQL_HOSTNAME=localhost
export MYSQL_USER=acuparse
export MYSQL_DATABASE=acuparse
export MYSQL_PASSWORD="${ACUPARSE_DB_PASSWORD}"
if [[ "$SQL_PW_SET" == false ]]; then
printf "ACUPARSE Database Password: ""${GREEN_TEXT}""${ACUPARSE_DB_PASSWORD}""${RESET_TEXT}""\n"
printf "${YELLOW_TEXT}""Credentials saved to ~/.acuparse_db""${RESET_TEXT}""\n\n"
fi
printf "\n"
exit 0
else
printf "${RED_TEXT}""FAILURE: Acuparse Installation Failed. Review acuparse.log for details!""${RESET_TEXT}""\n\n"
exit 1
fi
}
# Begin Install
printf "\nWelcome to the Acuparse Installation Script | Version: ""${SCRIPT_VERSION}""\n"
printf "${YELLOW_TEXT}""WARNING:""${RESET_TEXT}"" Only run this script on a freshly installed Debian/Raspbian Bullseye (11)/Buster (10) or Ubuntu Jammy (22.04)/Focal (20.04) system!\n\n"
# Ensure Debian/Ubuntu/Rasberian
if [[ ("$DIST" == "debian") || ("$DIST" == "ubuntu") || ("$DIST" == "raspbian") ]]; then
#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
cd ~ || exit 1
# Check Version
if [[ ("$DIST" == "debian") || ("$DIST" == "raspbian") ]]; then
if [[ "$DIST" == "raspbian" ]]; then
if [[ "$DEB_VERSION" == "\"10\"" ]]; then
PHP_VERSION="7.3"
printf "${GREEN_TEXT}""RASBIAN BUSTER(10) Successfully Detected!""${RESET_TEXT}""\n\n"
elif [[ "$DEB_VERSION" == "\"11\"" ]]; then
PHP_VERSION="7.4"
printf "${GREEN_TEXT}""RASBIAN BULLSEYE(11) Successfully Detected!""${RESET_TEXT}""\n\n"
else
printf "${RED_TEXT}""ERROR: UNSUPPORTED RASBIAN! REINSTALL USING RASBIAN BULLSEYE(11)""${RESET_TEXT}""\n"
exit 1
fi
else
if [[ "$DEB_VERSION" == "\"10\"" ]]; then
PHP_VERSION="7.3"
printf "${GREEN_TEXT}""DEBIAN BUSTER(10) Successfully Detected!""${RESET_TEXT}""\n\n"
elif [[ "$DEB_VERSION" == "\"11\"" ]]; then
PHP_VERSION="7.4"
printf "${GREEN_TEXT}""DEBIAN BULLSEYE(11) Successfully Detected!""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then
printf "${RED_TEXT}""Press [ENTER] to continue""${RESET_TEXT}""\n"
read -r READY
fi
else
printf "${RED_TEXT}""ERROR: UNSUPPORTED DEBIAN! REINSTALL USING DEBIAN BULLSEYE(11)""${RESET_TEXT}""\n"
exit 1
fi
fi
else
if [[ "$UBU_VERSION" == "22.04" ]]; then
PHP_VERSION="8.1"
UBUNTU_JAMMY=true
printf "${GREEN_TEXT}""Ubuntu Jammy (22.04) Successfully Detected!""${RESET_TEXT}""\n\n"
elif [[ "$UBU_VERSION" == "20.04" ]]; then
PHP_VERSION="7.4"
UBUNTU_FOCAL=true
printf "${GREEN_TEXT}""Ubuntu Focal(20.04) Successfully Detected!""${RESET_TEXT}""\n\n"
else
printf "${RED_TEXT}""ERROR: UNSUPPORTED UBUNTU! REINSTALL USING UBUNTU 22.04""${RESET_TEXT}""\n"
exit 1
fi
fi
if [[ "$SILENT" == false ]]; then
# Get user variables and setup install
printf "${BOLD_GREEN_TEXT}""####################\n# Pre-installation #\n####################""${RESET_TEXT}""\n\n"
printf "First, we'll configure your install:\n"
printf "${RED_TEXT}""When ready, Press [ENTER] to continue""${RESET_TEXT}""\n"
read -r READY
# Acuparse DB
printf "Enter NEW Acuparse database password, followed by [ENTER]:\n"
printf "${YELLOW_TEXT}""Make a note of this password, you will need it to finish your install""${RESET_TEXT}""\n"
stty -echo
read -r ACUPARSE_DB_PASSWORD
stty echo
SQL_PW_SET=true
# EXMIN
printf "Install Exim mail server?, y/N, followed by [ENTER]:\n"
read -r EXIM_ENABLED
# Let's Encrypt
printf "Configure SSL using Let's Encrypt?, y/N, followed by [ENTER]:\n"
read -r LE_SSL_ENABLED
if [[ ("$LE_SSL_ENABLED" == "y") || ("$LE_SSL_ENABLED" == "Y") ]]; then
printf "\nConfiguring Let's Encrypt\n\n"
printf "Enter FQDN(example.com/hostname.example.com), followed by [ENTER]:\n"
read -r LE_FQDN
printf "Also secure www.""$LE_FQDN""?, y/N, followed by [ENTER]:\n"
read -r LE_SECURE_WWW
printf "Certificate Email Address, followed by [ENTER]:\n"
read -r LE_EMAIL
printf "Redirect HTTP to HTTPS?, y/N, followed by [ENTER]:\n"
read -r LE_REDIRECT_ENABLED
fi
_run_timezone_set
printf "\n""${BOLD_GREEN_TEXT}""#######################\n# Installation Ready! #\n#######################""${RESET_TEXT}""\n\n"
printf "This process will install and configure packages.\nThis is your last chance to exit.\n\n"
printf "${RED_TEXT}""When ready, Press [ENTER] to continue""${RESET_TEXT}""\n"
read -r READY
fi
if [[ "$TZ_OPT_SET" == true ]]; then
_run_timezone_set
fi
# Begin Install
trap _cleanup exit
printf "${PURPLE_TEXT}""BEGIN: Starting Acuparse Installation""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
printf "${CYAN_TEXT}""BEGIN: Installing Packages""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
# Install CORE Packages
apt-get update
printf "${CYAN_TEXT}""Running Upgrade ...""${RESET_TEXT}""\n"
apt-get dist-upgrade -yqq
printf "${CYAN_TEXT}""Install CORE Packages""${RESET_TEXT}""\n"
apt-get install git dnsutils imagemagick apache2 default-mysql-server rsyslog cron -yqq || exit 1
systemctl restart mysql || systemctl restart mariadb || service mysql restart || service mariadb restart || exit 1
systemctl restart apache2 || service apache2 restart || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: CORE Packages""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
## INSTALL PHP
if [[ "$PHP_VERSION" == "8.1" ]]; then
printf "${CYAN_TEXT}""Installing PHP 8.1.""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
apt-get install php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-gd php8.1-curl php8.1-cli php8.1-common -yqq || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: Installing PHP 8.1.""${RESET_TEXT}""\n"
elif [[ "$PHP_VERSION" == "7.4" ]]; then
printf "${CYAN_TEXT}""Installing PHP 7.4.""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
apt-get install php7.4 libapache2-mod-php7.4 php7.4-mysql php7.4-gd php7.4-curl php7.4-json php7.4-cli php7.4-common -yqq || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: Installing PHP 7.4.""${RESET_TEXT}""\n"
elif [[ "$PHP_VERSION" == "7.3" ]]; then
printf "${CYAN_TEXT}""Installing PHP 7.3.""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
apt-get install php7.3 libapache2-mod-php7.3 php7.3-mysql php7.3-gd php7.3-curl php7.3-json php7.3-cli php7.3-common -yqq || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: Installing PHP 7.3.""${RESET_TEXT}""\n"
else
printf "${RED_TEXT}""ERROR: PHP INSTALL FAILED! Can't determine version to install.""${RESET_TEXT}""\n"
exit 1
fi
if [[ "$SILENT" == false ]]; then sleep 1; fi
# EXIM
if [[ ("$EXIM_ENABLED" == "y") || ("$EXIM_ENABLED" == "Y") ]]; then
printf "${CYAN_TEXT}""Installing Exim mail server""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
_run_exim_install
printf "${UNDERLINE_GREEN_TEXT}""DONE: Installing Exim mail server""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
fi
printf "${UNDERLINE_GREEN_TEXT}""DONE: Installing Packages""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
# Acuparse Source
printf "${CYAN_TEXT}""BEGIN: Install Acuparse via GIT""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
_run_acuparse_install || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: Install Acuparse via GIT""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
# Apache Config
printf "${CYAN_TEXT}""BEGIN: Configuring Apache""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
_run_apache_setup || exit 1
if [[ ("$LE_SSL_ENABLED" == "y") || ("$LE_SSL_ENABLED" == "Y") ]]; then
printf "${CYAN_TEXT}""Deploying Let's Encrypt Certificate""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
_install_le_cert
printf "${UNDERLINE_GREEN_TEXT}""DONE: Deploying Let's Encrypt Certificate""${RESET_TEXT}""\n"
fi
systemctl restart apache2 || service apache2 restart || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: Configuring Apache""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
# phpMyAdmin
if [[ ("$PHPMYADMIN_ENABLED" == "y") || ("$PHPMYADMIN_ENABLED" == "Y") ]]; then
printf "${CYAN_TEXT}""Installing phpMyAdmin""${RESET_TEXT}""\n"
_run_phpmyadmin_install
printf "${UNDERLINE_GREEN_TEXT}""DONE: Installing phpMyAdmin""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
fi
# Database Config
printf "${CYAN_TEXT}""BEGIN: Creating Acuparse Database""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
_run_database_install || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: Creating Acuparse Database""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
# Crontab Config
printf "${CYAN_TEXT}""BEGIN: Installing Cron""${RESET_TEXT}""\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
(
crontab -l 2>/dev/null
echo "* * * * * /usr/bin/php /opt/acuparse/cron/cron.php > /opt/acuparse/logs/cron.log 2>&1"
) | crontab -
printf "${UNDERLINE_GREEN_TEXT}""DONE: Installing Cron""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
# Installation Cleanup
printf "${CYAN_TEXT}""BEGIN: Running Cleanup""${RESET_TEXT}""\n"
_openSSL
apt-get autoremove -y
apt-get clean -y
apt-get purge -y
systemctl restart mysql || systemctl restart mariadb || service mysql restart || service mariadb restart || exit 1
systemctl restart apache2 || service apache2 restart || exit 1
printf "${UNDERLINE_GREEN_TEXT}""DONE: Running Cleanup""${RESET_TEXT}""\n\n"
if [[ "$SILENT" == false ]]; then sleep 1; fi
# Done Install
exit 0
# No Supported OS
else
printf "${RED_TEXT}""ERROR: This script is designed to be run on a freshly installed Debian/Raspbian Bullseye (11)/Buster (10) or Ubuntu Jammy (22.04)/Focal (20.04) system""${RESET_TEXT}""\n"
exit 1
fi