Skip to content

Commit 0eb1109

Browse files
authored
Debug and Error Logs
Added a debug mode that closely tracks errors and prompts the use to continue after each install step. Also enhanced general error logging during install and added a persistant error log that will contain all errors encountered during the installation process.
1 parent b86b184 commit 0eb1109

7 files changed

Lines changed: 182 additions & 70 deletions

File tree

config/etc/logrotate.d/enginescript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
sharedscripts
1010

1111
prerotate
12-
if [ "$1" = "/var/log/EngineScript/install-log.txt" ]; then
13-
# Skip rotation for install log
12+
if [ "$1" = "/var/log/EngineScript/install-log.txt" ] || [ "$1" = "/var/log/EngineScript/install-error-log.txt" ]; then
13+
# Skip rotation for install log and install error log
1414
exit 0
1515
fi
1616
endscript

config/home/enginescript-install-options.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#| Choose one of the methods below:
99
#|
1010
#| At console, type: es.config
11-
#| At console, type: es.menu and select option 7, then option 3
1211
#| At console, type /home/EngineScript/enginescript-install-options.txt
1312

1413
###################
@@ -17,6 +16,13 @@
1716
# 0 = disabled
1817
# 1 = enabled
1918

19+
# EngineScript Install Debug Mode
20+
# Prompts the user to continue or exit after each portion of the install script has run.
21+
# Debug mode will print any errors that each install script encounters.
22+
# Regardless of whether debug mode is enabled, EngineScript will generate a complete log of the script errors will be located at touch /var/log/EngineScript/install-error-log.txt
23+
# Run command es.debug to generate a complete server and error log. This is useful when submitting a GitHub issue.
24+
DEBUG_INSTALL=0
25+
2026
# Admin Subdomain (Recommended)
2127
# This will add an admin subdomain (example: admin.wordpresstesting.com) to your site, allowing you to access your server's admin control panel directly from any site installed on your server. You can also access it directly via your server's IP address.
2228
ADMIN_SUBDOMAIN=1
@@ -35,11 +41,11 @@ INSTALL_ADMINER=0
3541
# 0 = disabled
3642
# 1 = enabled
3743

38-
# EngineScript Daily Updates
44+
# EngineScript Daily Updates (Recommended)
3945
# Adds a cronjob that pulls the latest EngineScript release and updates your installation to that version.
4046
ENGINESCRIPT_AUTO_UPDATE=1
4147

42-
# EngineScript Emergency Updates
48+
# EngineScript Emergency Updates (Recommended)
4349
# Recommended if you allow EngineScript to auto-update. In the event that a change is pushed live that breaks servers, this emergency-only script will run to attempt a self-heal.
4450
# This script runs hourly, but will not contain any code unless there is a code issue that warrants emergency measures be taken.
4551
ENGINESCRIPT_AUTO_EMERGENCY_UPDATES=1

scripts/functions/alias/alias-debug.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@ NORMAL="\e[0m"
1313
GREEN="\e[32m"
1414
YELLOW="\e[33m"
1515

16-
# Function to write to both console and file
16+
# Persistent error log path
17+
ERROR_LOG="/var/log/EngineScript/install-error-log.txt"
18+
19+
# Function to log errors to persistent error log
20+
log_error() {
21+
echo -e "$1" >> "$ERROR_LOG"
22+
}
23+
24+
# Function to write to both console, file, and error log if applicable
1725
debug_print() {
1826
echo -e "$1"
1927
echo -e "$2" >> "$DEBUG_FILE"
28+
if [[ "$1" == *"ERROR"* || "$1" == *"FAILED"* ]]; then
29+
log_error "$1"
30+
fi
2031
}
2132

2233
# Get server info from alias-server-info.sh functions
@@ -31,7 +42,9 @@ get_server_info() {
3142
UBUNTU_CODENAME=$(lsb_release -c | cut -f2)
3243

3344
# CPU Info
34-
CPU_INFO=$(lscpu | grep -E "^Model name:" | cut -d":" -f2 | xargs)
45+
if ! CPU_INFO=$(lscpu | grep -E "^Model name:" | cut -d":" -f2 | xargs); then
46+
debug_print "ERROR: Failed to retrieve CPU model information." "ERROR: Failed to retrieve CPU model information."
47+
fi
3548
CPU_CORES=$(nproc)
3649
CPU_FREQ=$(lscpu | grep -E "^CPU MHz:" | cut -d":" -f2 | xargs)
3750

@@ -166,6 +179,9 @@ debug_print "${NGINX_MODULES}" "${NGINX_MODULES}"
166179
debug_print "\`\`\`\n" "\`\`\`\n"
167180

168181
debug_print "#### NGINX Configuration Test\n" "#### NGINX Configuration Test\n"
182+
if ! nginx -t 2>&1; then
183+
debug_print "ERROR: NGINX configuration test failed." "ERROR: NGINX configuration test failed."
184+
fi
169185
debug_print "\`\`\`" "\`\`\`"
170186
NGINX_TEST=$(nginx -t 2>&1)
171187
debug_print "${NGINX_TEST}" "${NGINX_TEST}"
@@ -273,3 +289,9 @@ cat << 'EOF' >> "$DEBUG_FILE"
273289
## Actual Behavior
274290
<!-- What actually happened? -->
275291
EOF
292+
293+
# Append install error log if it exists
294+
if [ -f /var/log/EngineScript/install-error-log.txt ]; then
295+
echo -e "\n## EngineScript Install Error Log (Full Contents)\n" >> "$DEBUG_FILE"
296+
cat /var/log/EngineScript/install-error-log.txt >> "$DEBUG_FILE"
297+
fi

0 commit comments

Comments
 (0)