-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-wp.sh
executable file
·44 lines (34 loc) · 1.41 KB
/
install-wp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/bash
# Includes your config file
source config.sh
if [ $# -ne 1 ]; then
echo $0: usage: Destination Name
exit 1
fi
DEST=$1
# Create the database.
DB_NAME=$(echo $DEST | sed -e 's/-/_/g')
echo "Creating database $DB_NAME..."
random-string()
{
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}
PASSWORD_ALEATORIO=$(random-string)
#Clean name of characters
DB_NAME_CLEAN="${DB_NAME//./}"
mysql -u$DB_USER -p$DB_PASS -e"CREATE DATABASE $DB_NAME_CLEAN DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
mysql -u$DB_USER -p$DB_PASS -e"CREATE USER $DB_NAME_CLEAN@localhost IDENTIFIED BY '$PASSWORD_ALEATORIO';"
mysql -u$DB_USER -p$DB_PASS -e"GRANT ALL ON $DB_NAME_CLEAN.* TO '$DB_NAME_CLEAN'@'localhost' IDENTIFIED BY '$PASSWORD_ALEATORIO'; FLUSH PRIVILEGES;"
# Download WP Core.
wp core download --path=$SITE_PATH/$DEST
# Generate the wp-config.php file
wp core config --path=$SITE_PATH/$DEST --dbname=$DB_NAME_CLEAN --dbuser=$DB_NAME_CLEAN --dbpass=$PASSWORD_ALEATORIO --extra-php <<PHP
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
define('WP_MEMORY_LIMIT', '256M');
PHP
# Install the WordPress database.
wp core install --path=$SITE_PATH/$DEST --url=$BASE_URL/$DEST --title=$DEST --admin_user=test --admin_password=test [email protected]
sudo ln -s $SITE_PATH/$DEST /var/www/$DEST
sudo ./virtualhost/virtualhost.sh create $DEST $DEST