Skip to content

Commit 3e8a460

Browse files
CopilotPDowney
andauthored
Fix: replace undefined SITE_URL with DOMAIN in vhost-install.sh
Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/7391fd26-fe98-4e95-bdf9-5950ba60c0a9 Co-authored-by: PDowney <[email protected]>
1 parent 6491d17 commit 3e8a460

2 files changed

Lines changed: 49 additions & 45 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Changes are organized by date, with the most recent changes listed first.
66

77
## 2026-04-11
88

9+
### 🐛 VHOST INSTALL BUG FIX
10+
11+
- Fixed undefined variable `SITE_URL` used throughout `scripts/functions/vhost/vhost-install.sh`; replaced all occurrences with the correct `DOMAIN` variable (defined at line 84). Affected areas include database credential logging, WordPress download, wp-config.php setup, Redis/salt/wpconfig configuration, file permissions, WP-CLI install, plugin installation, placeholder page, backups, and summary output.
12+
913
### 🔧 VHOST IMPORT BUG FIXES & IMPROVEMENTS
1014

1115
- Updated the single-zip database file detection in `scripts/functions/vhost/vhost-import.sh` to search for both `*.sql` and `*.sql.gz` patterns, so compressed database dumps are correctly found and imported instead of failing silently.

scripts/functions/vhost/vhost-install.sh

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
168168

169169
source "/home/EngineScript/mysql-credentials/${DOMAIN}.txt"
170170

171-
echo "Randomly generated MySQL database credentials for ${SITE_URL}."
171+
echo "Randomly generated MySQL database credentials for ${DOMAIN}."
172172

173173
sudo mariadb -e "CREATE DATABASE ${DB} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
174174
sudo mariadb -e "CREATE USER '${USR}'@'localhost' IDENTIFIED BY '${PSWD}';"
@@ -177,48 +177,48 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
177177

178178
# Download WordPress using WP-CLI
179179
wp core download --allow-root
180-
rm -f "/var/www/sites/${SITE_URL}/html/wp-content/plugins/hello.php"
180+
rm -f "/var/www/sites/${DOMAIN}/html/wp-content/plugins/hello.php"
181181

182182
# Create Extra WordPress Directories
183183
# WordPress often doesn't include these directories by default, despite them being used or checked in the Health Check plugin.
184-
create_extra_wp_dirs "${SITE_URL}"
184+
create_extra_wp_dirs "${DOMAIN}"
185185

186186
# Create wp-config.php
187-
cp -rf /usr/local/bin/enginescript/config/var/www/wordpress/wp-config.php "/var/www/sites/${SITE_URL}/html/wp-config.php"
188-
sed -i "s|SEDWPDB|${DB}|g" "/var/www/sites/${SITE_URL}/html/wp-config.php"
189-
sed -i "s|SEDWPUSER|${USR}|g" "/var/www/sites/${SITE_URL}/html/wp-config.php"
190-
sed -i "s|SEDWPPASS|${PSWD}|g" "/var/www/sites/${SITE_URL}/html/wp-config.php"
191-
sed -i "s|SEDPREFIX|${PREFIX}|g" "/var/www/sites/${SITE_URL}/html/wp-config.php"
192-
sed -i "s|SEDURL|${SITE_URL}|g" "/var/www/sites/${SITE_URL}/html/wp-config.php"
187+
cp -rf /usr/local/bin/enginescript/config/var/www/wordpress/wp-config.php "/var/www/sites/${DOMAIN}/html/wp-config.php"
188+
sed -i "s|SEDWPDB|${DB}|g" "/var/www/sites/${DOMAIN}/html/wp-config.php"
189+
sed -i "s|SEDWPUSER|${USR}|g" "/var/www/sites/${DOMAIN}/html/wp-config.php"
190+
sed -i "s|SEDWPPASS|${PSWD}|g" "/var/www/sites/${DOMAIN}/html/wp-config.php"
191+
sed -i "s|SEDPREFIX|${PREFIX}|g" "/var/www/sites/${DOMAIN}/html/wp-config.php"
192+
sed -i "s|SEDURL|${DOMAIN}|g" "/var/www/sites/${DOMAIN}/html/wp-config.php"
193193

194194
# Configure Redis for WordPress
195-
configure_redis "${SITE_URL}" "/var/www/sites/${SITE_URL}/html/wp-config.php"
195+
configure_redis "${DOMAIN}" "/var/www/sites/${DOMAIN}/html/wp-config.php"
196196

197197
# WP Salt Creation
198-
fetch_wp_salts "/var/www/sites/${SITE_URL}/html/wp-config.php"
198+
fetch_wp_salts "/var/www/sites/${DOMAIN}/html/wp-config.php"
199199

200200
# Configure wp-config.php settings
201-
configure_wpconfig_settings "${SITE_URL}" "/var/www/sites/${SITE_URL}/html/wp-config.php"
201+
configure_wpconfig_settings "${DOMAIN}" "/var/www/sites/${DOMAIN}/html/wp-config.php"
202202

203203
# Create robots.txt file
204-
create_robots_txt "${SITE_URL}" "/var/www/sites/${SITE_URL}/html"
204+
create_robots_txt "${DOMAIN}" "/var/www/sites/${DOMAIN}/html"
205205

206206
# WP File Permissions
207-
find "/var/www/sites/${SITE_URL}" -type d -print0 | sudo xargs -0 chmod 0755
208-
find "/var/www/sites/${SITE_URL}" -type f -print0 | sudo xargs -0 chmod 0644
209-
chown -R www-data:www-data "/var/www/sites/${SITE_URL}"
210-
chmod +x "/var/www/sites/${SITE_URL}/html/wp-cron.php"
211-
chmod 600 "/var/www/sites/${SITE_URL}/html/wp-config.php"
207+
find "/var/www/sites/${DOMAIN}" -type d -print0 | sudo xargs -0 chmod 0755
208+
find "/var/www/sites/${DOMAIN}" -type f -print0 | sudo xargs -0 chmod 0644
209+
chown -R www-data:www-data "/var/www/sites/${DOMAIN}"
210+
chmod +x "/var/www/sites/${DOMAIN}/html/wp-cron.php"
211+
chmod 600 "/var/www/sites/${DOMAIN}/html/wp-config.php"
212212

213213
# WP-CLI Finalizing Install
214214
clear
215215
echo "============================================="
216-
echo "Finalizing ${SITE_URL} Install:"
216+
echo "Finalizing ${DOMAIN} Install:"
217217
echo "============================================="
218218

219219
# WP-CLI Install WordPress
220-
cd "/var/www/sites/${SITE_URL}/html"
221-
wp core install --admin_user="${WP_ADMIN_USERNAME}" --admin_password="${WP_ADMIN_PASSWORD}" --admin_email="${WP_ADMIN_EMAIL}" --url="https://${SITE_URL}" --title='New Site' --skip-email --allow-root
220+
cd "/var/www/sites/${DOMAIN}/html"
221+
wp core install --admin_user="${WP_ADMIN_USERNAME}" --admin_password="${WP_ADMIN_PASSWORD}" --admin_email="${WP_ADMIN_EMAIL}" --url="https://${DOMAIN}" --title='New Site' --skip-email --allow-root
222222

223223
clear_wordpress_caches
224224

@@ -233,7 +233,7 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
233233
fi
234234

235235
# Install EngineScript custom plugins if enabled
236-
install_enginescript_custom_plugins "${SITE_URL}"
236+
install_enginescript_custom_plugins "${DOMAIN}"
237237

238238
# Clear WordPress caches, transients, and rewrite rules
239239
clear_wordpress_caches
@@ -254,41 +254,41 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
254254
# Setting Permissions Again
255255
# For whatever reason, using WP-CLI to install plugins with --allow-root reassigns
256256
# the ownership of the /uploads, /upgrade, and plugin directories to root:root.
257-
cd "/var/www/sites/${SITE_URL}"
258-
chown -R www-data:www-data "/var/www/sites/${SITE_URL}"
259-
chmod +x "/var/www/sites/${SITE_URL}/html/wp-cron.php"
260-
find "/var/www/sites/${SITE_URL}" -type d -print0 | sudo xargs -0 chmod 0755
261-
find "/var/www/sites/${SITE_URL}" -type f -print0 | sudo xargs -0 chmod 0644
262-
chmod 600 "/var/www/sites/${SITE_URL}/html/wp-config.php"
257+
cd "/var/www/sites/${DOMAIN}"
258+
chown -R www-data:www-data "/var/www/sites/${DOMAIN}"
259+
chmod +x "/var/www/sites/${DOMAIN}/html/wp-cron.php"
260+
find "/var/www/sites/${DOMAIN}" -type d -print0 | sudo xargs -0 chmod 0755
261+
find "/var/www/sites/${DOMAIN}" -type f -print0 | sudo xargs -0 chmod 0644
262+
chmod 600 "/var/www/sites/${DOMAIN}/html/wp-config.php"
263263

264264
clear
265265

266266
# Perform site backup
267-
perform_site_backup "${SITE_URL}" "/var/www/sites/${SITE_URL}/html"
267+
perform_site_backup "${DOMAIN}" "/var/www/sites/${DOMAIN}/html"
268268

269269
# Display final credentials summary
270-
display_credentials_summary "${SITE_URL}" "${DB}" "${PREFIX}" "${USR}" "${PSWD}"
270+
display_credentials_summary "${DOMAIN}" "${DB}" "${PREFIX}" "${USR}" "${PSWD}"
271271

272272
else
273273
#----------------------------------------------------------------------------------
274274
# Non-WordPress Installation Path (Placeholder Page)
275275
#----------------------------------------------------------------------------------
276276

277-
echo "Installing placeholder page for ${SITE_URL}..."
277+
echo "Installing placeholder page for ${DOMAIN}..."
278278

279279
# Install placeholder page
280-
cp -f /usr/local/bin/enginescript/config/var/www/placeholder/index.html "/var/www/sites/${SITE_URL}/html/index.html"
281-
sed -i "s|YOURDOMAIN|${SITE_URL}|g" "/var/www/sites/${SITE_URL}/html/index.html"
280+
cp -f /usr/local/bin/enginescript/config/var/www/placeholder/index.html "/var/www/sites/${DOMAIN}/html/index.html"
281+
sed -i "s|YOURDOMAIN|${DOMAIN}|g" "/var/www/sites/${DOMAIN}/html/index.html"
282282

283283
# Set file permissions
284-
find "/var/www/sites/${SITE_URL}" -type d -print0 | sudo xargs -0 chmod 0755
285-
find "/var/www/sites/${SITE_URL}" -type f -print0 | sudo xargs -0 chmod 0644
286-
chown -R www-data:www-data "/var/www/sites/${SITE_URL}"
284+
find "/var/www/sites/${DOMAIN}" -type d -print0 | sudo xargs -0 chmod 0755
285+
find "/var/www/sites/${DOMAIN}" -type f -print0 | sudo xargs -0 chmod 0644
286+
chown -R www-data:www-data "/var/www/sites/${DOMAIN}"
287287

288288
# Backup nginx vhost and SSL keys
289289
NOW=$(date +%m-%d-%Y-%H)
290-
gzip -cf "/etc/nginx/sites-enabled/${SITE_URL}.conf" > "/home/EngineScript/site-backups/${SITE_URL}/nginx/${NOW}-nginx-vhost.conf.gz"
291-
tar -zcf "/home/EngineScript/site-backups/${SITE_URL}/ssl-keys/${NOW}-ssl-keys.gz" "/etc/nginx/ssl/${SITE_URL}"
290+
gzip -cf "/etc/nginx/sites-enabled/${DOMAIN}.conf" > "/home/EngineScript/site-backups/${DOMAIN}/nginx/${NOW}-nginx-vhost.conf.gz"
291+
tar -zcf "/home/EngineScript/site-backups/${DOMAIN}/ssl-keys/${NOW}-ssl-keys.gz" "/etc/nginx/ssl/${DOMAIN}"
292292

293293
clear
294294

@@ -297,15 +297,15 @@ else
297297
echo "|${BOLD} Domain Summary (No WordPress)${NORMAL} |"
298298
echo "-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-"
299299
echo ""
300-
echo "${BOLD}URL:${NORMAL} ${SITE_URL}"
300+
echo "${BOLD}URL:${NORMAL} ${DOMAIN}"
301301
echo ""
302-
echo "Site root: /var/www/sites/${SITE_URL}/html"
303-
echo "Nginx vhost: /etc/nginx/sites-enabled/${SITE_URL}.conf"
304-
echo "SSL certificates: /etc/nginx/ssl/${SITE_URL}/"
305-
echo "Backups: /home/EngineScript/site-backups/${SITE_URL}/"
302+
echo "Site root: /var/www/sites/${DOMAIN}/html"
303+
echo "Nginx vhost: /etc/nginx/sites-enabled/${DOMAIN}.conf"
304+
echo "SSL certificates: /etc/nginx/ssl/${DOMAIN}/"
305+
echo "Backups: /home/EngineScript/site-backups/${DOMAIN}/"
306306
echo ""
307307
echo "A placeholder page has been installed. Replace"
308-
echo "/var/www/sites/${SITE_URL}/html/index.html with your own content."
308+
echo "/var/www/sites/${DOMAIN}/html/index.html with your own content."
309309
echo "-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-"
310310
echo ""
311311
sleep 3
@@ -320,7 +320,7 @@ echo ""
320320
echo " Domain setup completed."
321321
echo ""
322322
echo " Your domain should be available now at:"
323-
echo " https://${SITE_URL}"
323+
echo " https://${DOMAIN}"
324324
echo ""
325325
echo " Returning to main menu in 5 seconds."
326326
echo ""

0 commit comments

Comments
 (0)