-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathenginescript-install.sh
More file actions
301 lines (246 loc) · 13.6 KB
/
enginescript-install.sh
File metadata and controls
301 lines (246 loc) · 13.6 KB
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
#!/usr/bin/env bash
#----------------------------------------------------------------------------
# EngineScript - A High-Performance WordPress Server Built on Ubuntu and Cloudflare
#----------------------------------------------------------------------------
# Website: https://EngineScript.com
# GitHub: https://github.com/Enginescript/EngineScript
# Company: VisiStruct / EngineScript
# License: GPL v3.0
#----------------------------------------------------------------------------
# Check current user's ID. If user is not 0 (root), exit.
if [[ "${EUID}" -ne 0 ]];
then
echo "${BOLD}ALERT:${NORMAL}"
echo "EngineScript should be executed as the root user."
exit 1
fi
#----------------------------------------------------------------------------
# Start Main Script
# dos2unix
# In-case you uploaded the options file using a basic Windows text editor
dos2unix /home/EngineScript/enginescript-install-options.txt
# Convert line endings
dos2unix /usr/local/bin/enginescript/*
# Set directory and file permissions to 755
find /usr/local/bin/enginescript -exec chmod 755 {} \;
# Set ownership
chown -R root:root /usr/local/bin/enginescript
# Make shell scripts executable
find /usr/local/bin/enginescript -type f -iname "*.sh" -exec chmod +x {} \;
# EngineScript Variables
source /usr/local/bin/enginescript/enginescript-variables.txt || { echo "Error: Failed to source /usr/local/bin/enginescript/enginescript-variables.txt" >&2; exit 1; }
source /home/EngineScript/enginescript-install-options.txt || { echo "Error: Failed to source /home/EngineScript/enginescript-install-options.txt" >&2; exit 1; }
# Source shared functions library
source /usr/local/bin/enginescript/scripts/functions/shared/enginescript-common.sh || { echo "Error: Failed to source /usr/local/bin/enginescript/scripts/functions/shared/enginescript-common.sh" >&2; exit 1; }
# Reboot Warning
echo -e "\nATTENTION:\n\nServer needs to reboot at the end of this script.\nEnter command es.menu after reboot to continue.\n\nScript will continue in 5 seconds..." | boxes -a c -d shell -p a1l2
sleep 5
if [[ "${SERVER_MEMORY_TOTAL_80}" -lt 1000 ]];
then
echo "WARNING: Total server memory is low."
echo "It is recommended that a server running EngineScript has at least 2GB total memory."
echo "EngineScript will attempt to configure memory settings that will work for a 1GB server, but performance is not guaranteed."
echo "You may need to manually change memory limits in PHP and MariaDB."
sleep 10
else
echo "Memory Test: 80% of total server memory: ${SERVER_MEMORY_TOTAL_80}"
fi
# Configuration File Check
echo -e "${BOLD}\n\n--------------------\nConfiguration Review\n--------------------${NORMAL}"
echo -e "${BOLD}\nServer Information:${NORMAL}"
echo "Script Run Date = $DT"
echo "CPU Count = $CPU_COUNT"
echo "32bit or 64bit = $BIT_TYPE"
echo "Server Memory = $SERVER_MEMORY_TOTAL_100"
echo "IP Address = $IP_ADDRESS"
echo "Linux Version = $UBUNTU_TYPE $UBUNTU_VERSION $UBUNTU_CODENAME"
# Detect server location and hosting provider
detect_server_location
# Auto-detect DigitalOcean and enable features if applicable
auto_detect_digitalocean
echo -e "${BOLD}\nEngineScript Install Options:${NORMAL}"
echo "AUTOMATIC_LOSSLESS_IMAGE_OPTIMIZATION = $AUTOMATIC_LOSSLESS_IMAGE_OPTIMIZATION"
echo "ENGINESCRIPT_AUTO_UPDATE = $ENGINESCRIPT_AUTO_UPDATE"
echo "ADMIN_SUBDOMAIN = $ADMIN_SUBDOMAIN"
echo "INSTALL_ADMINER = $INSTALL_ADMINER"
echo "INSTALL_PHPMYADMIN = $INSTALL_PHPMYADMIN"
echo "SHOW_ENGINESCRIPT_HEADER = $SHOW_ENGINESCRIPT_HEADER"
echo "DAILY_LOCAL_DATABASE_BACKUP = $DAILY_LOCAL_DATABASE_BACKUP"
echo "HOURLY_LOCAL_DATABASE_BACKUP = $HOURLY_LOCAL_DATABASE_BACKUP"
echo "WEEKLY_LOCAL_WPCONTENT_BACKUP = $WEEKLY_LOCAL_WPCONTENT_BACKUP"
echo "INSTALL_S3_BACKUP = $INSTALL_S3_BACKUP"
echo "DAILY_S3_DATABASE_BACKUP = $DAILY_S3_DATABASE_BACKUP"
echo "HOURLY_S3_DATABASE_BACKUP = $HOURLY_S3_DATABASE_BACKUP"
echo "WEEKLY_S3_WPCONTENT_BACKUP = $WEEKLY_S3_WPCONTENT_BACKUP"
echo -e "${BOLD}\nUser Credentials:${NORMAL}"
echo "S3_BUCKET_NAME = $S3_BUCKET_NAME"
echo "CF_GLOBAL_API_KEY = $CF_GLOBAL_API_KEY"
echo "CF_ACCOUNT_EMAIL = $CF_ACCOUNT_EMAIL"
echo "ADMIN_CONTROL_PANEL_USERNAME = $ADMIN_CONTROL_PANEL_USERNAME"
echo "ADMIN_CONTROL_PANEL_PASSWORD = $ADMIN_CONTROL_PANEL_PASSWORD"
echo "MARIADB_ADMIN_PASSWORD = $MARIADB_ADMIN_PASSWORD"
echo "PHPMYADMIN_USERNAME = $PHPMYADMIN_USERNAME"
echo "PHPMYADMIN_PASSWORD = $PHPMYADMIN_PASSWORD"
echo "FILEMANAGER_USERNAME = $FILEMANAGER_USERNAME"
echo "FILEMANAGER_PASSWORD = $FILEMANAGER_PASSWORD"
echo "UPTIMEROBOT_API_KEY = $UPTIMEROBOT_API_KEY"
echo "WP_ADMIN_EMAIL = $WP_ADMIN_EMAIL"
echo "WP_ADMIN_USERNAME = $WP_ADMIN_USERNAME"
echo "WP_ADMIN_PASSWORD = $WP_ADMIN_PASSWORD"
echo "PUSHBULLET_TOKEN = $PUSHBULLET_TOKEN"
echo "WORDFENCE_CLI_TOKEN = $WORDFENCE_CLI_TOKEN"
echo "WPSCANAPI = $WPSCANAPI"
echo -e "\n"
sleep 5
# Warn if EngineScript automatic updates are disabled
if [[ "${ENGINESCRIPT_AUTO_UPDATE}" = "0" ]]; then
echo -e "\n${BOLD}WARNING: EngineScript Automatic Updates are DISABLED.${NORMAL}\n"
echo -e "You will need to manually apply updates to the EngineScript application and configuration files if updates are released in the future."
while true; do
read -p "Would you like to enable automatic updates now? (y/n/exit): " yn_auto_update
case $yn_auto_update in
[Yy]* )
sed -i 's/^ENGINESCRIPT_AUTO_UPDATE=0/ENGINESCRIPT_AUTO_UPDATE=1/' /home/EngineScript/enginescript-install-options.txt
ENGINESCRIPT_AUTO_UPDATE=1
if grep -q '^ENGINESCRIPT_AUTO_EMERGENCY_UPDATES=0' /home/EngineScript/enginescript-install-options.txt; then
sed -i 's/^ENGINESCRIPT_AUTO_EMERGENCY_UPDATES=0/ENGINESCRIPT_AUTO_EMERGENCY_UPDATES=1/' /home/EngineScript/enginescript-install-options.txt
ENGINESCRIPT_AUTO_EMERGENCY_UPDATES=1
echo -e "\nEmergency auto updates have also been enabled.\n"
fi
echo -e "\nAutomatic updates have been enabled.\n"
sleep 2
break
;;
[Nn]* )
echo -e "\nAutomatic updates remain disabled.\n"
sleep 2
break
;;
[Ee][Xx][Ii][Tt]* )
echo -e "\nExiting install script as requested.\n"
exit 1
;;
* ) echo "Please answer yes, no, or exit.";;
esac
done
fi
# Check S3 Install
if [[ "$INSTALL_S3_BACKUP" = 1 ]]; then
validate_not_placeholder "S3_BUCKET_NAME" "$S3_BUCKET_NAME" "You have set INSTALL_S3_BACKUP=1 but have not properly set S3_BUCKET_NAME.\nPlease return to the config file with command ${BOLD}es.config${NORMAL} and change S3_BUCKET_NAME to show your bucket name instead of PLACEHOLDER\nYou can also disabled S3 cloud backup by setting INSTALL_S3_BACKUP=0"
fi
# Check Cloudflare Credentials
validate_not_placeholder "CF_GLOBAL_API_KEY" "$CF_GLOBAL_API_KEY" "CF_GLOBAL_API_KEY is set to PLACEHOLDER. EngineScript requires this be set prior to installation.\nPlease return to the config file with command ${BOLD}es.config${NORMAL} and change CF_GLOBAL_API_KEY to the correct value."
validate_not_placeholder "CF_ACCOUNT_EMAIL" "$CF_ACCOUNT_EMAIL" "CF_ACCOUNT_EMAIL is set to PLACEHOLDER. EngineScript requires this be set prior to installation.\nPlease return to the config file with command ${BOLD}es.config${NORMAL} and change CF_ACCOUNT_EMAIL to the correct value."
# Check Credentials
validate_not_placeholder "MARIADB_ADMIN_PASSWORD" "$MARIADB_ADMIN_PASSWORD"
validate_not_placeholder "PHPMYADMIN_USERNAME" "$PHPMYADMIN_USERNAME"
validate_not_placeholder "PHPMYADMIN_PASSWORD" "$PHPMYADMIN_PASSWORD"
validate_not_placeholder "FILEMANAGER_USERNAME" "$FILEMANAGER_USERNAME"
validate_not_placeholder "FILEMANAGER_PASSWORD" "$FILEMANAGER_PASSWORD"
validate_not_placeholder "WP_ADMIN_EMAIL" "$WP_ADMIN_EMAIL" "WP_ADMIN_EMAIL is set to PLACEHOLDER. EngineScript requires this be set to a unique value.\nPlease return to the config file with command ${BOLD}es.config${NORMAL} and change WP_ADMIN_EMAIL to a real email address."
# Check/fix WordPress Recovery Email
if [[ "$WP_RECOVERY_EMAIL" = PLACEHOLDER ]]; then
sed -i "s|PLACEHOLDER@PLACEHOLDER\.com|${WP_ADMIN_EMAIL}|g" /home/EngineScript/enginescript-install-options.txt
fi
validate_not_placeholder "WP_ADMIN_USERNAME" "$WP_ADMIN_USERNAME"
validate_not_placeholder "WP_ADMIN_PASSWORD" "$WP_ADMIN_PASSWORD"
# Install Check
source /var/log/EngineScript/install-log.log
# Repositories
run_install_step "REPOS" "/usr/local/bin/enginescript/scripts/install/repositories/repositories-install.sh" "Install Repositories"
# Remove Preinstalled Software
run_install_step "REMOVES" "/usr/local/bin/enginescript/scripts/install/removes/remove-preinstalled.sh" "Remove Preinstalled Software"
# Block Unwanted Packages
run_install_step "BLOCK" "/usr/local/bin/enginescript/scripts/install/block/package-block.sh" "Block Unwanted Packages"
# Ubuntu Pro Setup
run_install_step "UBUNTU_PRO" "/usr/local/bin/enginescript/scripts/install/ubuntu-pro/ubuntu-pro-install.sh" "Ubuntu Pro Setup"
# Update & Upgrade
/usr/local/bin/enginescript/scripts/functions/enginescript-apt-update.sh 2>> /tmp/enginescript_install_errors.log
print_last_errors
debug_pause "Update & Upgrade"
# Install Dependencies
run_install_step "DEPENDS" "/usr/local/bin/enginescript/scripts/install/depends/depends-install.sh" "Install Dependencies"
# Cron
run_install_step "CRON" "/usr/local/bin/enginescript/scripts/install/cron/cron-install.sh" "Cron"
# ACME.sh
run_install_step "ACME" "/usr/local/bin/enginescript/scripts/install/acme/acme-install.sh" "ACME.sh"
# GCC
run_install_step "GCC" "/usr/local/bin/enginescript/scripts/install/gcc/gcc-install.sh" "GCC"
# OpenSSL
run_install_step "OPENSSL" "/usr/local/bin/enginescript/scripts/install/openssl/openssl-install.sh" "OpenSSL"
# Swap
run_install_step "SWAP" "/usr/local/bin/enginescript/scripts/install/swap/swap-install.sh" "Swap"
# Kernel Tweaks
run_install_step "KERNEL_TWEAKS" "/usr/local/bin/enginescript/scripts/install/kernel/kernel-tweaks-install.sh" "Kernel Tweaks"
# Kernel Samepage Merging
run_install_step "KSM" "/usr/local/bin/enginescript/scripts/install/kernel/ksm.sh" "Kernel Samepage Merging"
# Raising System File Limits
run_install_step "SFL" "/usr/local/bin/enginescript/scripts/install/system-misc/file-limits.sh" "Raising System File Limits"
# NTP
run_install_step "NTP" "/usr/local/bin/enginescript/scripts/install/systemd/timesyncd.sh" "NTP"
# DigitalOcean Remote Console (optional)
if [[ "${INSTALL_DIGITALOCEAN_REMOTE_CONSOLE}" = "1" ]]; then
run_install_step "DO_CONSOLE" "/usr/local/bin/enginescript/scripts/install/system-misc/digitalocean-software-install.sh" "DigitalOcean Remote Console"
fi
# PCRE
run_install_step "PCRE" "/usr/local/bin/enginescript/scripts/install/pcre/pcre-install.sh" "PCRE"
# zlib
run_install_step "ZLIB" "/usr/local/bin/enginescript/scripts/install/zlib/zlib-install.sh" "zlib"
# liburing
run_install_step "LIBURING" "/usr/local/bin/enginescript/scripts/install/liburing/liburing-install.sh" "liburing"
# UFW
run_install_step "UFW" "/usr/local/bin/enginescript/scripts/install/ufw/ufw-install.sh" "UFW"
# MariaDB
run_install_step "MARIADB" "/usr/local/bin/enginescript/scripts/install/mariadb/mariadb-install.sh" "MariaDB"
# PHP
run_install_step "PHP" "/usr/local/bin/enginescript/scripts/install/php/php-install.sh" "PHP"
# Redis
run_install_step "REDIS" "/usr/local/bin/enginescript/scripts/install/redis/redis-install.sh" "Redis"
# Nginx
run_install_step "NGINX" "/usr/local/bin/enginescript/scripts/install/nginx/nginx-install.sh" "Nginx"
# Tools
run_install_step "TOOLS" "/usr/local/bin/enginescript/scripts/install/tools/tools-install.sh" "Tools"
# --------------------------------------------------------
# Final Installation Completion Verification
echo ""
echo "============================================================="
echo "Final Installation Verification"
echo "============================================================="
echo ""
# Verify all components completed successfully
if check_installation_completion "true"; then
echo "🎉 SUCCESS: EngineScript installation completed successfully!"
echo "🎉 All 24 core components have been installed and verified."
echo ""
echo "Installation Summary:"
echo "✅ System repositories and dependencies"
echo "✅ Security and firewall configuration"
echo "✅ Core services (MariaDB, PHP, Redis, Nginx)"
echo "✅ SSL/TLS and build environment"
echo "✅ System optimization and tools"
echo ""
else
echo "⚠️ WARNING: Installation verification detected some incomplete components."
echo "⚠️ This may indicate errors during installation that need attention."
echo ""
echo "RECOMMENDATION:"
echo "1. Review /var/log/EngineScript/install-error-log.log for any errors"
echo "2. Use 'es.debug' command after reboot to generate a diagnostic report"
echo "3. Consider re-running the installation script to complete missing components"
echo ""
fi
echo "============================================================="
echo ""
# Cleanup
/usr/local/bin/enginescript/scripts/functions/php-clean.sh
/usr/local/bin/enginescript/scripts/functions/enginescript-cleanup.sh
# Server Reboot
clear
# Display Install Info
/usr/local/bin/enginescript/scripts/functions/alias/alias-server-info.sh
# Reboot Notice
echo -e "${BOLD}Server needs to reboot.${NORMAL}\n\nEnter command ${BOLD}es.menu${NORMAL} after reboot to continue.\n" | boxes -a c -d shell -p a1l2
sleep 10
clear
echo -e "Server rebooting now...\n\n${NORMAL}When reconnected, use command ${BOLD}es.menu${NORMAL} to start EngineScript.\nSelect option 1 to create a new vhost configuration on your server.\n\n${BOLD}Bye! Manually reconnect in 30 seconds.\n" | boxes -a c -d shell -p a1l2
shutdown -r now