Created
October 10, 2018 03:49
-
-
Save andrewwoods/efae605e0f06cce7f99e31b78a23d99a to your computer and use it in GitHub Desktop.
WordPress Install Bash Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Client website setup script | |
# | |
echo "Commencing WordPress trunk Setup" | |
DB_NAME="name_of_database" | |
DB_USER="database_username" | |
DB_PASS="database_password" | |
# | |
# Make a database, if we don't already have one | |
# | |
echo "Creating database (if it's not already there)" | |
mysql -u root --password=${DB_PASS} \ | |
-e "CREATE DATABASE IF NOT EXISTS ${DB_NAME}" | |
mysql -u root --password=$DB_PASS \ | |
-e "GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO ${DB_USER}@localhost IDENTIFIED BY '${DB_USER}';" | |
# | |
# Check for the presence of a `htdocs` folder. | |
# If `htdocs` folder doesn't exist, check out WordPress as that folder | |
# | |
if [ ! -d htdocs ] | |
then | |
echo "Checking out GitHub project" | |
git clone https://github.com/username/project.git htdocs | |
# Use WP CLI to create a `wp-config.php` file | |
wp core config --dbname="${DB_NAME}" \ | |
--dbuser=${DB_USER} \ | |
--dbpass=${DB_USER} \ | |
--dbhost="localhost" \ | |
--allow-root | |
# Use WP CLI to install WordPress | |
wp core install --url= \ | |
--title="WordPress Trunk Auto" \ | |
--admin_user=admin \ | |
--admin_password=password \ | |
[email protected] \ | |
--allow-root | |
# | |
# Change folder to the parent folder of `htdocs` | |
# | |
cd .. | |
else | |
echo "Updating Git Website" | |
# If the `htdocs` folder exists, then run SVN update | |
cd htdocs | |
git pull | |
cd .. | |
fi | |
# | |
# The Vagrant site setup script will restart Nginx for us | |
# | |
# Let the user know the good news | |
echo "WordPress client website now installed"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment