-
Notifications
You must be signed in to change notification settings - Fork 1
/
vvv-init.sh
24 lines (19 loc) · 979 Bytes
/
vvv-init.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
#!/bin/bash
set -e
printf "## -------------------------------------------------- ##"
printf "Setting up: %s\n" $(basename $(pwd))
# Export required PHP constants into Bash.
printf "Creating database, if we don't already have one."
eval $(php -r '
require_once( "vvv-config.php" );
foreach( explode( " ", "DB_NAME DB_HOST DB_USER DB_PASSWORD DB_CHARSET WP_HOME" ) as $key ) {
echo $key . "=" . constant( $key ) . PHP_EOL;
}
')
mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS $DB_NAME CHARACTER SET $DB_CHARSET"
mysql -u root --password=root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO $DB_USER@localhost IDENTIFIED BY '$DB_PASSWORD';"
if ! $(wp core is-installed --allow-root); then
wp --allow-root core install --url="$WP_HOME" --title="VIP Go Site" --admin_user="admin" --admin_password="password" --admin_email="admin@127.0.0.1"
fi
printf "Finished setting up: %s\n" $(basename $(pwd))
printf "## -------------------------------------------------- ##"