You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Fixed `domain_without_tld` extraction in `scripts/functions/vhost/vhost-install.sh` to correctly handle multi-part TLDs (e.g., `co.uk`, `com.au`, `org.nz`). For a domain like `example.co.uk` the extracted base is now `example` instead of `example.co`, preventing unexpected database naming.
12
+
- Added `chmod 600` on the MySQL credentials file immediately after writing it in `scripts/functions/vhost/vhost-install.sh`, ensuring sensitive database credentials are protected from unauthorised access by other system users.
13
+
- Clarified the warning message when WP-CLI fails to delete the default `hello` plugin: the new message reads "It may already be deleted or another error occurred. Continuing installation." instead of the misleading "Continuing if plugin is already absent."
14
+
- Added pre-install validation of WordPress admin credentials (`WP_ADMIN_USERNAME`, `WP_ADMIN_PASSWORD`, `WP_ADMIN_EMAIL`) in `scripts/functions/vhost/vhost-install.sh` before calling `wp core install`, enforcing non-empty values, a valid username format (3-60 alphanumeric/underscore/dot/hyphen characters), a valid email address format, and a minimum password complexity of 12+ characters with upper, lower, digit, and special-character requirements.
echo"Randomly generated MySQL database credentials for ${DOMAIN}."
174
188
@@ -190,7 +204,7 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
190
204
# Download WordPress using WP-CLI
191
205
wp core download --allow-root
192
206
if! wp plugin delete hello --allow-root;then
193
-
echo"Warning: Failed to delete default 'hello' plugin via WP-CLI. Continuing if plugin is already absent."
207
+
echo"Warning: Failed to delete default 'hello' plugin via WP-CLI. It may already be deleted or another error occurred. Continuing installation."
194
208
fi
195
209
196
210
# Create Extra WordPress Directories
@@ -232,6 +246,35 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
232
246
233
247
# WP-CLI Install WordPress
234
248
cd"/var/www/sites/${DOMAIN}/html"
249
+
250
+
# Validate WordPress admin credentials before install
251
+
if [[ -z"${WP_ADMIN_USERNAME}"||-z"${WP_ADMIN_PASSWORD}"||-z"${WP_ADMIN_EMAIL}" ]];then
252
+
echo"Error: WP admin credentials must not be empty (WP_ADMIN_USERNAME, WP_ADMIN_PASSWORD, WP_ADMIN_EMAIL).">&2
253
+
exit 1
254
+
fi
255
+
256
+
# Username: 3-60 chars, must start with alphanumeric, letters/numbers/underscore/dot/hyphen
257
+
if [[ !"${WP_ADMIN_USERNAME}"=~ ^[A-Za-z0-9][A-Za-z0-9_.-]{2,59}$ ]];then
258
+
echo"Error: WP_ADMIN_USERNAME is invalid. Use 3-60 characters: letters, numbers, underscore, dot, or hyphen.">&2
259
+
exit 1
260
+
fi
261
+
262
+
# Email: basic format validation
263
+
if [[ !"${WP_ADMIN_EMAIL}"=~ ^[A-Za-z0-9][A-Za-z0-9._%+-]*[A-Za-z0-9]@[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)*\.[A-Za-z]{2,}$ ]];then
264
+
echo"Error: WP_ADMIN_EMAIL is not a valid email address format.">&2
265
+
exit 1
266
+
fi
267
+
268
+
# Password: minimum complexity requirements
269
+
if [[ ${#WP_ADMIN_PASSWORD}-lt 12 ]] || \
270
+
[[ !"${WP_ADMIN_PASSWORD}"=~ [A-Z] ]] || \
271
+
[[ !"${WP_ADMIN_PASSWORD}"=~ [a-z] ]] || \
272
+
[[ !"${WP_ADMIN_PASSWORD}"=~ [0-9] ]] || \
273
+
[[ !"${WP_ADMIN_PASSWORD}"=~ [^A-Za-z0-9] ]];then
274
+
echo"Error: WP_ADMIN_PASSWORD must be at least 12 characters and include uppercase, lowercase, number, and special character.">&2
0 commit comments