Update install_wordpress_vestacp
This commit is contained in:
parent
f9b91fda22
commit
1097bca957
@ -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]
|
||||
</FilesMatch>
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user