Skip to content

Instantly share code, notes, and snippets.

@darkoromanov
Last active March 27, 2018 20:59
Show Gist options
  • Save darkoromanov/564a9435a7b1cab3575e2a3aa638cfdc to your computer and use it in GitHub Desktop.
Save darkoromanov/564a9435a7b1cab3575e2a3aa638cfdc to your computer and use it in GitHub Desktop.
Bash script to create a new WordPress installation and install (and activate) a plugin. This is a prototype for a (much) more complex tool, it only performs tasks without checking if they fail.
#this is just a prototype, it performs tasks without checking if someone fails
clear
#db user
user=root
#db password
password=root
#db name
database=testing
#directory where to install WordPress
dir=testing
#admin user
user=admin
#admin password
user_pwd=admin
#email of the admin user
email=myreal@email.com
#url of the test site
url=localhost:8888
#path of the plugin to install
plugin_path=/Applications/MAMP/htdocs/final-tiles-gallery-dev/wp-content/plugins/final-tiles-grid-gallery-lite.zip
#plugin name
plugin_name=final-tiles-grid-gallery-lite
echo "deleting old files..."
rm -fr $dir/*
cd $dir
echo "Dropping database..."
mysql --user="$user" --password="$password" --database="$database" --execute="DROP DATABASE $database;"
echo "Downloading core...."
wp core download
echo "Creating configuration file..."
wp config create --dbname=$database --dbuser=$user --dbpass=$password
echo "Creating database...."
wp db create
echo "Installing...."
wp core install --url=$url/$dir --title=Testing --admin_user=$user --admin_password=$user_pwd --admin_email=$email
echo "Installing plugin..."
wp plugin install $plugin_path
echo "Activating plugin..."
wp plugin activate $plugin_name
echo "Populating plugin..."
mysql --user="$user" --password="$password" --database="$database" < ../data.sql
echo "Creating post..."
wp post create --post_type=post --post_title='Test' --post_content='[FinalTilesGallery id=1]' --post_name='test' --post_status='publish'
open http://$url/$dir/test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment