Update install_wordpress_vestacp
This commit is contained in:
parent
f9b91fda22
commit
1097bca957
@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# bash <(curl -s https://git.technozone.com.au/vijay/Scripts/raw/branch/main/install_wordpress_vestacp) && rm -f install_wordpress_vestacp
|
# 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
|
# Function to prompt for input with default value
|
||||||
prompt() {
|
prompt() {
|
||||||
local prompt_message=$1
|
local prompt_message=$1
|
||||||
@ -16,25 +15,16 @@ prompt() {
|
|||||||
USERNAME=$(prompt "Enter username" "default_user")
|
USERNAME=$(prompt "Enter username" "default_user")
|
||||||
DOMAIN_NAME=$(prompt "Enter domain name" "example.com")
|
DOMAIN_NAME=$(prompt "Enter domain name" "example.com")
|
||||||
|
|
||||||
# Check if domain already exists
|
# Extract the domain name without the TLD
|
||||||
if v-list-web-domains $USERNAME | grep -q $DOMAIN_NAME; then
|
DOMAIN_NO_TLD=$(echo "$DOMAIN_NAME" | cut -d '.' -f 1)
|
||||||
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)
|
|
||||||
|
|
||||||
# Truncate the username to ensure the total length does not exceed 16 characters
|
# Truncate the username to ensure the total length does not exceed 16 characters
|
||||||
MAX_USERNAME_LENGTH=16
|
MAX_USERNAME_LENGTH=16
|
||||||
TRUNCATED_USERNAME=$(echo "$USERNAME" | cut -c1-10) # Limit to 10 characters
|
TRUNCATED_USERNAME=$(echo "$USERNAME" | cut -c1-10) # Limit to 10 characters
|
||||||
|
|
||||||
# Construct database name and user without the last two parts
|
# Construct database name and user
|
||||||
DB_NAME="${TRUNCATED_USERNAME}_${DB_PREFIX}" # Construct database name
|
DB_NAME="${TRUNCATED_USERNAME}_${DOMAIN_NO_TLD}_d" # Construct database name
|
||||||
DB_USER="${TRUNCATED_USERNAME}_${DB_PREFIX}" # Construct database user
|
DB_USER="${TRUNCATED_USERNAME}_${DOMAIN_NO_TLD}_u" # Construct database user
|
||||||
|
|
||||||
# Ensure the database name and user do not exceed 16 characters
|
# Ensure the database name and user do not exceed 16 characters
|
||||||
if [ ${#DB_NAME} -gt $MAX_USERNAME_LENGTH ]; then
|
if [ ${#DB_NAME} -gt $MAX_USERNAME_LENGTH ]; then
|
||||||
@ -47,9 +37,14 @@ fi
|
|||||||
|
|
||||||
DB_PASS=$(openssl rand -base64 6 | tr -d "=+/")
|
DB_PASS=$(openssl rand -base64 6 | tr -d "=+/")
|
||||||
|
|
||||||
# Create MySQL database and user
|
# Check if domain already exists
|
||||||
echo "Creating database and user..."
|
if v-list-web-domains $USERNAME | grep -q $DOMAIN_NAME; then
|
||||||
v-add-database $USERNAME $DB_NAME $DB_USER $DB_PASS
|
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
|
# Download and extract WordPress
|
||||||
echo "Downloading and installing WordPress..."
|
echo "Downloading and installing WordPress..."
|
||||||
@ -95,6 +90,10 @@ RewriteRule . /index.php [L]
|
|||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
EOL
|
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
|
# Create WordPress configuration file
|
||||||
echo "Configuring WordPress..."
|
echo "Configuring WordPress..."
|
||||||
cp $WP_DIR/wp-config-sample.php $WP_DIR/wp-config.php
|
cp $WP_DIR/wp-config-sample.php $WP_DIR/wp-config.php
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user