From 1097bca9577e21d4f2b31884b09ae4df98c36f91 Mon Sep 17 00:00:00 2001 From: vijay Date: Mon, 5 May 2025 23:41:20 +0000 Subject: [PATCH] Update install_wordpress_vestacp --- install_wordpress_vestacp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/install_wordpress_vestacp b/install_wordpress_vestacp index fda9ac1..cb9551e 100644 --- a/install_wordpress_vestacp +++ b/install_wordpress_vestacp @@ -1,7 +1,6 @@ #!/bin/bash # bash <(curl -s https://git.technozone.com.au/vijay/Scripts/raw/branch/main/install_wordpress_vestacp) && rm -f install_wordpress_vestacp - # Function to prompt for input with default value prompt() { local prompt_message=$1 @@ -16,25 +15,16 @@ prompt() { USERNAME=$(prompt "Enter username" "default_user") DOMAIN_NAME=$(prompt "Enter domain name" "example.com") -# Check if domain already exists -if v-list-web-domains $USERNAME | grep -q $DOMAIN_NAME; then - echo "Domain $DOMAIN_NAME already exists." -else - # Create domain if it does not exist - echo "Creating domain $DOMAIN_NAME for user $USERNAME..." - v-add-domain $USERNAME $DOMAIN_NAME -fi - -# Define 3-character database and user prefix based on domain name -DB_PREFIX=$(echo $DOMAIN_NAME | cut -c1-3) +# Extract the domain name without the TLD +DOMAIN_NO_TLD=$(echo "$DOMAIN_NAME" | cut -d '.' -f 1) # Truncate the username to ensure the total length does not exceed 16 characters MAX_USERNAME_LENGTH=16 TRUNCATED_USERNAME=$(echo "$USERNAME" | cut -c1-10) # Limit to 10 characters -# Construct database name and user without the last two parts -DB_NAME="${TRUNCATED_USERNAME}_${DB_PREFIX}" # Construct database name -DB_USER="${TRUNCATED_USERNAME}_${DB_PREFIX}" # Construct database user +# Construct database name and user +DB_NAME="${TRUNCATED_USERNAME}_${DOMAIN_NO_TLD}_d" # Construct database name +DB_USER="${TRUNCATED_USERNAME}_${DOMAIN_NO_TLD}_u" # Construct database user # Ensure the database name and user do not exceed 16 characters if [ ${#DB_NAME} -gt $MAX_USERNAME_LENGTH ]; then @@ -47,9 +37,14 @@ fi DB_PASS=$(openssl rand -base64 6 | tr -d "=+/") -# Create MySQL database and user -echo "Creating database and user..." -v-add-database $USERNAME $DB_NAME $DB_USER $DB_PASS +# Check if domain already exists +if v-list-web-domains $USERNAME | grep -q $DOMAIN_NAME; then + echo "Domain $DOMAIN_NAME already exists." +else + # Create domain if it does not exist + echo "Creating domain $DOMAIN_NAME for user $USERNAME..." + v-add-domain $USERNAME $DOMAIN_NAME +fi # Download and extract WordPress echo "Downloading and installing WordPress..." @@ -95,6 +90,10 @@ RewriteRule . /index.php [L] EOL +# Create MySQL database and user +echo "Creating database and user..." +v-add-database $USERNAME $DB_NAME $DB_USER $DB_PASS + # Create WordPress configuration file echo "Configuring WordPress..." cp $WP_DIR/wp-config-sample.php $WP_DIR/wp-config.php