-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-build.sh
executable file
·45 lines (37 loc) · 1.32 KB
/
wp-build.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
45
#!/usr/bin/env bash
# Wordpress build script.
# Build a new site quickly from the command line.
# Database connection details, you will have to add your own in here.
dbhost="localhost"
dbuser="root"
dbpass="root"
answer=$1
echo "Starting Wordpress Build"
if [ $# -eq 0 ]
then
echo "Please enter a name for this site: "
read answer
if [ ! -z "$answer" ]
then
echo "Thank You, continuing build..."
else
echo "No data supplied, exiting"
fi
fi
# Make a database, we will use the website name as the db name
echo "Creating database $answer (if it's not already there)"
mysql -u $dbuser --password=$dbpass -e "CREATE DATABASE IF NOT EXISTS $answer"
mysql -u $dbuser --password=$dbpass -e "CREATE USER '$answer'@'localhost' IDENTIFIED BY '$answer'"
mysql -u $dbuser --password=$dbpass -e "GRANT ALL PRIVILEGES ON $answer.* TO $answer@localhost IDENTIFIED BY '$answer';"
# Download WordPress to a directory named after our site.
if [ ! -d $answer ]
then
echo "Installing WordPress using WP CLI"
mkdir $answer
cd $answer
wp core download
wp core config --dbname="$answer" --dbuser=$answer --dbpass=$answer --dbhost="localhost"
wp core install --url=$answer.local --title="$answer" --admin_user=admin --admin_password=$answer --admin_email=demo@example.com
cd ..
fi
echo "Wordpress site built and ready!";