So I started using Alfred a few weeks ago, and just realized how awesome it is, so I decided to put together a WordPress Workflow. I'd like to share it, but I'd also like some feedback on cleaning it up (if needed), and how to create a config file for default settings such as WordPress user, password, email, so that I can keep sensitive data separate from the actual script. I'm running AMPPS for testing, and it all works. I borrowed code from a few different places.
Thanks.
# MAMP fix path
#export PATH=/Applications/MAMP/bin/php/php5.6.1/bin:$PATH
#export PATH=$PATH:/usr/local/bin:/Applications/MAMP/Library/bin
# AMPPS fix path
export PATH=/Applications/AMPPS/php-5.6/bin:$PATH
export PATH=$PATH:/Applications/AMPPS/mysql/bin
query="{query}"
# MYSQL Credentials
mysqluser="user"
mysqlpassword="123456"
# Database Credentials
dbhost="localhost"
dbname=$query
dbuser=$query
dbpass=$(openssl rand -base64 16)
#WordPress Config
admin_user="admin"
admin_password="abc123"
admin_email="name@example.com"
# Create directory for new site
cd /Applications/AMPPS/www
mkdir $query
cd $query
# Create Database
/Applications/AMPPS/mysql/bin/mysql -u $mysqluser -p$mysqlpassword -e "CREATE DATABASE $dbname;"
/Applications/AMPPS/mysql/bin/mysql -u $mysqluser -p$mysqlpassword -e "GRANT ALL PRIVILEGES ON $dbname.* TO $dbuser@localhost IDENTIFIED BY '$dbpass';"
/Applications/AMPPS/mysql/bin/mysql -u $dbuser -p$dbpass -e "use $dbname;"
/Applications/AMPPS/mysql/bin/mysql -u $mysqluser -p$mysqlpassword -e "CREATE USER '$dbuser' IDENTIFIED BY '$dbpass';"
# Download latest version of WordPress
/usr/local/bin/wp core download
# Setup wp-config file with WP_DEBUG enabled
/usr/local/bin/wp core config --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpass
# Install WordPress
/usr/local/bin/wp core install --url="http://www.vanwp.ca/{query}" --title="{query}" --admin_user=$admin_user --admin_password=$admin_password --admin_email=$admin_email