-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathinstall.sh
executable file
·307 lines (242 loc) · 8.43 KB
/
install.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
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
#!/usr/bin/env bash
# +-------------------------------------------------------------------------+
# | LEMPer is a simple LEMP stack installer for Debian/Ubuntu Linux |
# |-------------------------------------------------------------------------+
# | Min requirement : GNU/Linux Debian 8, Ubuntu 18.04 or Linux Mint 17 |
# | Last Update : 13/02/2022 |
# | Author : MasEDI.Net ([email protected]) |
# | Version : 2.x.x |
# +-------------------------------------------------------------------------+
# | Copyright (c) 2014-2022 MasEDI.Net (https://masedi.net/lemper) |
# +-------------------------------------------------------------------------+
# | This source file is subject to the GNU General Public License |
# | that is bundled with this package in the file LICENSE.md. |
# | |
# | If you did not receive a copy of the license and are unable to |
# | obtain it through the world-wide-web, please send an email |
# | to [email protected] so we can send you a copy immediately. |
# +-------------------------------------------------------------------------+
# | Authors: Edi Septriyanto <[email protected]> |
# +-------------------------------------------------------------------------+
# Work even if somebody does "bash install.sh".
#set -exv -o pipefail # For verbose output.
set -e -o pipefail
# Try to re-export global path.
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Get installer base directory.
export BASE_DIR && \
BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
# Include helper functions.
if [[ "$(type -t run)" != "function" ]]; then
. "${BASE_DIR}/scripts/utils.sh"
fi
# Make sure only root can run this installer script.
requires_root "$@"
# Make sure only supported distribution can run this installer script.
preflight_system_check
##
# Main LEMPer Installer
#
header_msg
echo "Starting LEMPer Stack installation..."
echo "Please ensure that you're on a fresh install!"
if [[ "${AUTO_INSTALL}" != true ]]; then
echo ""
read -t 60 -rp "Press [Enter] to continue..." </dev/tty
fi
# Init log.
run init_log
# Init config.
run init_config
### Install dependencies packages ###
if [ -f ./scripts/install_dependencies.sh ]; then
echo ""
. ./scripts/install_dependencies.sh
fi
### Server clean-up ###
if [ -f ./scripts/server_cleanup.sh ]; then
echo ""
. ./scripts/server_cleanup.sh
fi
### Create default account ###
echo ""
LEMPER_USERNAME=${LEMPER_USERNAME:-"lemper"}
create_account "${LEMPER_USERNAME}"
### Certbot Let's Encrypt SSL installation ###
if [ -f ./scripts/install_certbotle.sh ]; then
echo ""
. ./scripts/install_certbotle.sh
fi
### Nginx installation ###
if [ -f ./scripts/install_nginx.sh ]; then
echo ""
. ./scripts/install_nginx.sh
fi
### PHP installation ###
if [ -f ./scripts/install_php.sh ]; then
echo ""
. ./scripts/install_php.sh
fi
### Phalcon PHP installation ###
if [ -f ./scripts/install_phalcon.sh ]; then
echo ""
. ./scripts/install_phalcon.sh
fi
### MySQL database installation ###
if [ -f ./scripts/install_mariadb.sh ]; then
echo ""
. ./scripts/install_mariadb.sh
fi
### PostgreSQL database installation ###
if [ -f ./scripts/install_postgres.sh ]; then
echo ""
. ./scripts/install_postgres.sh
fi
### Redis database installation ###
if [ -f ./scripts/install_redis.sh ]; then
echo ""
. ./scripts/install_redis.sh
fi
### MongoDB database installation ###
if [ -f ./scripts/install_mongodb.sh ]; then
echo ""
. ./scripts/install_mongodb.sh
fi
### Memcached installation ###
if [ -f ./scripts/install_memcached.sh ]; then
echo ""
. ./scripts/install_memcached.sh
fi
### Imagick installation ###
if [ -f ./scripts/install_imagemagick.sh ]; then
echo ""
. ./scripts/install_imagemagick.sh
fi
### Mail server installation ###
if [ -f ./scripts/install_mailer.sh ]; then
echo ""
. ./scripts/install_mailer.sh
fi
### FTP installation ###
if [[ "${FTP_SERVER_NAME}" == "pureftpd" || "${FTP_SERVER_NAME}" == "pure-ftpd" ]]; then
if [ -f ./scripts/install_pureftpd.sh ]; then
echo ""
. ./scripts/install_pureftpd.sh
fi
else
if [ -f ./scripts/install_vsftpd.sh ]; then
echo ""
. ./scripts/install_vsftpd.sh
fi
fi
### Fail2ban, intrusion prevention software framework. ###
if [ -f ./scripts/install_fail2ban.sh ]; then
echo ""
. ./scripts/install_fail2ban.sh
fi
### LEMPer tools installation ###
if [ -f ./scripts/install_tools.sh ]; then
echo ""
. ./scripts/install_tools.sh
fi
### Basic server optimization ###
if [ -f ./scripts/server_optimization.sh ]; then
echo ""
. ./scripts/server_optimization.sh
fi
### Basic server security setup ###
if [ -f ./scripts/server_security.sh ]; then
echo ""
. ./scripts/server_security.sh
fi
### FINAL SETUP ###
if [[ "${FORCE_REMOVE}" == true ]]; then
# Cleaning up all build dependencies hanging around on production server?
echo -e "\nClean up installation process..."
run apt-get autoremove -q -y
# Cleanup build dir
echo "Clean up build directory..."
if [ -d "${BUILD_DIR}" ]; then
run rm -fr "${BUILD_DIR}"
fi
fi
if [[ "${DRYRUN}" != true ]]; then
status -e "\nCongrats, your LEMPer Stack installation has been completed."
### Recap ###
if [[ -n "${LEMPER_PASSWORD}" ]]; then
CREDENTIALS="
~~~~~~~~~~~~~~~~~~~~~~~~~o0o~~~~~~~~~~~~~~~~~~~~~~~~~
Default system information:
Hostname : ${HOSTNAME}
Server IP: ${SERVER_IP}
SSH Port : ${SSH_PORT}
LEMPer Stack admin account:
Username : ${LEMPER_USERNAME}
Password : ${LEMPER_PASSWORD}
Database administration (Adminer):
http://${SERVER_IP}:8082/lcp/dbadmin/
MySQL root password: ${MYSQL_ROOT_PASSWORD}
Mariabackup user information:
DB Username: ${MARIABACKUP_USER}
DB Password: ${MARIABACKUP_PASS}"
if [[ "${INSTALL_POSTGRES}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
PostgreSQL user information:
Postgres Superuser: ${POSTGRES_SUPERUSER}
Postgres DB Username: ${POSTGRES_DB_USER}
Postgres DB Password: ${POSTGRES_DB_PASS}"
fi
if [[ "${INSTALL_MONGODB}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
MongoDB test admin login:
Username : ${MONGODB_ADMIN_USER}
Password : ${MONGODB_ADMIN_PASSWORD}"
fi
if [[ "${INSTALL_REDIS}" == true && "${REDIS_REQUIRE_PASSWORD}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
Redis required password enabled:
Password : ${REDIS_PASSWORD}"
fi
if [[ "${INSTALL_MEMCACHED}" == true && "${MEMCACHED_SASL}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
Memcached SASL login:
Username : ${MEMCACHED_USERNAME}
Password : ${MEMCACHED_PASSWORD}"
fi
if [[ "${INSTALL_MAILER}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
Default Mail service:
Maildir : /home/${LEMPER_USERNAME}/Maildir
Sender Domain: ${SENDER_DOMAIN}
Sender IP : ${SERVER_IP}
IMAP Port : 143, 993 (SSL/TLS)
POP3 Port : 110, 995 (SSL/TLS)
Domain Key : ${DOMAIN_KEY}
DKIM Key : ${DKIM_KEY}
SPF Record : ${SPF_RECORD}
Use your default LEMPer stack admin account for Mail login."
fi
CREDENTIALS="${CREDENTIALS}
File manager (TinyFileManager):
http://${SERVER_IP}:8082/lcp/filemanager/
Use your default LEMPer stack admin account for Filemanager login.
Please Save the above Credentials & Keep it Secure!
~~~~~~~~~~~~~~~~~~~~~~~~~o0o~~~~~~~~~~~~~~~~~~~~~~~~~"
status "${CREDENTIALS}"
# Send credentials to admin email.
run bash -c "echo '${CREDENTIALS}' | mail -s 'LEMPer Stack Credentials for ${SERVER_IP}' ${LEMPER_ADMIN_EMAIL}"
# Save it to log file
#save_log "${CREDENTIALS}"
# Securing LEMPer stack credentials.
#secure_config
fi
else
warning -e "\nLEMPer installation has been completed in dry-run mode."
fi
echo "
See the log file (lemper.log) for more information.
Now, you can reboot your server and enjoy it!
"
info "SECURITY PRECAUTION! Due to the log file contains some credential data,
You SHOULD delete it after your stack completely installed."
footer_msg