Skip to content

Commit 20be9f5

Browse files
CopilotPDowney
andcommitted
Fix: Quote SSL_KEYLENGTH, add wget/unzip error handling, document sourced functions
Co-authored-by: PDowney <[email protected]> Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/7b0ce91e-26fc-4bc8-bbdd-cdbe60a9f588
1 parent a2d4cdf commit 20be9f5

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to EngineScript will be documented in this file.
44

55
Changes are organized by date, with the most recent changes listed first.
66

7+
## 2026-03-20
8+
9+
### 🔒 VHOST SCRIPT ROBUSTNESS AND SAFETY IMPROVEMENTS
10+
11+
- **Quoted `SSL_KEYLENGTH` variable** in `scripts/functions/shared/enginescript-shared-vhost.sh`.
12+
- Changed `-k ${SSL_KEYLENGTH}` to `-k "${SSL_KEYLENGTH}"` to prevent word-splitting issues if the variable is empty or contains spaces.
13+
- **Added error handling** for `wget` and `unzip` commands in `install_enginescript_custom_plugins()`.
14+
- Downloads and extractions now fail fast (`return 1`) with a clear error message and temp directory cleanup if a download or extraction fails.
15+
- **Added source documentation comment** to `enginescript-shared-vhost.sh` header.
16+
- Documents that `prompt_yes_no()` and `restart_service()` are provided by `enginescript-common.sh` and must be sourced before this file.
17+
718
## 2026-03-03
819

920
### 🌐 NON-WORDPRESS DOMAIN SUPPORT (Tasks 113 & 114)

scripts/functions/shared/enginescript-shared-vhost.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
# Shared Virtual Host Functions
1010
# This file contains common functions used by both vhost-install.sh and vhost-import.sh
1111
#----------------------------------------------------------------------------------
12+
# Note: This file requires enginescript-common.sh to be sourced before it.
13+
# The following functions are defined in enginescript-common.sh and used here:
14+
# - prompt_yes_no() : Prompts the user for a yes/no answer with optional default and timeout
15+
# - restart_service() : Restarts a named system service via systemctl or service
16+
#----------------------------------------------------------------------------------
1217

1318

1419
# Check if required services are running
@@ -115,7 +120,7 @@ create_ssl_certificate() {
115120
mkdir -p "/etc/nginx/ssl/${DOMAIN}"
116121

117122
# Issue SSL Certificate
118-
/root/.acme.sh/acme.sh --issue --force --dns dns_cf --server zerossl -d "${DOMAIN}" -d "admin.${DOMAIN}" -d "*.${DOMAIN}" -k ${SSL_KEYLENGTH}
123+
/root/.acme.sh/acme.sh --issue --force --dns dns_cf --server zerossl -d "${DOMAIN}" -d "admin.${DOMAIN}" -d "*.${DOMAIN}" -k "${SSL_KEYLENGTH}"
119124

120125
# Install SSL Certificate
121126
/root/.acme.sh/acme.sh --install-cert -d "${DOMAIN}" --ecc \
@@ -637,14 +642,30 @@ install_enginescript_custom_plugins() {
637642

638643
# 1. EngineScript Site Optimizer plugin
639644
mkdir -p "/tmp/enginescript-es-so-plugin"
640-
wget -q "https://github.com/EngineScript/enginescript-site-optimizer/releases/download/v${ES_SO_PLUGIN_VER}/enginescript-site-optimizer-${ES_SO_PLUGIN_VER}.zip" -O "/tmp/enginescript-es-so-plugin/enginescript-site-optimizer-${ES_SO_PLUGIN_VER}.zip"
641-
unzip -q -o "/tmp/enginescript-es-so-plugin/enginescript-site-optimizer-${ES_SO_PLUGIN_VER}.zip" -d "/var/www/sites/${SITE_URL}/html/wp-content/plugins/"
645+
wget -q "https://github.com/EngineScript/enginescript-site-optimizer/releases/download/v${ES_SO_PLUGIN_VER}/enginescript-site-optimizer-${ES_SO_PLUGIN_VER}.zip" -O "/tmp/enginescript-es-so-plugin/enginescript-site-optimizer-${ES_SO_PLUGIN_VER}.zip" || {
646+
echo "ERROR: Failed to download EngineScript Site Optimizer plugin (version ${ES_SO_PLUGIN_VER})."
647+
rm -rf "/tmp/enginescript-es-so-plugin"
648+
return 1
649+
}
650+
unzip -q -o "/tmp/enginescript-es-so-plugin/enginescript-site-optimizer-${ES_SO_PLUGIN_VER}.zip" -d "/var/www/sites/${SITE_URL}/html/wp-content/plugins/" || {
651+
echo "ERROR: Failed to extract EngineScript Site Optimizer plugin archive."
652+
rm -rf "/tmp/enginescript-es-so-plugin"
653+
return 1
654+
}
642655
rm -rf "/tmp/enginescript-es-so-plugin"
643656

644657
# 2. EngineScript Site Exporter plugin
645658
mkdir -p "/tmp/enginescript-es-se-plugin"
646-
wget -q "https://github.com/EngineScript/enginescript-site-exporter/releases/download/v${ES_SE_PLUGIN_VER}/enginescript-site-exporter-${ES_SE_PLUGIN_VER}.zip" -O "/tmp/enginescript-es-se-plugin/enginescript-site-exporter-${ES_SE_PLUGIN_VER}.zip"
647-
unzip -q -o "/tmp/enginescript-es-se-plugin/enginescript-site-exporter-${ES_SE_PLUGIN_VER}.zip" -d "/var/www/sites/${SITE_URL}/html/wp-content/plugins/"
659+
wget -q "https://github.com/EngineScript/enginescript-site-exporter/releases/download/v${ES_SE_PLUGIN_VER}/enginescript-site-exporter-${ES_SE_PLUGIN_VER}.zip" -O "/tmp/enginescript-es-se-plugin/enginescript-site-exporter-${ES_SE_PLUGIN_VER}.zip" || {
660+
echo "ERROR: Failed to download EngineScript Site Exporter plugin (version ${ES_SE_PLUGIN_VER})."
661+
rm -rf "/tmp/enginescript-es-se-plugin"
662+
return 1
663+
}
664+
unzip -q -o "/tmp/enginescript-es-se-plugin/enginescript-site-exporter-${ES_SE_PLUGIN_VER}.zip" -d "/var/www/sites/${SITE_URL}/html/wp-content/plugins/" || {
665+
echo "ERROR: Failed to extract EngineScript Site Exporter plugin archive."
666+
rm -rf "/tmp/enginescript-es-se-plugin"
667+
return 1
668+
}
648669
rm -rf "/tmp/enginescript-es-se-plugin"
649670
else
650671
echo "Skipping EngineScript custom plugins installation (disabled in config)..."

0 commit comments

Comments
 (0)