bhubbard
4/3/2014 - 10:35 PM

wpinstall.sh

#!/bin/bash

# Input database name
echo "---"
echo "wpinstall.sh - A WordPress installation shell script"
echo "by Rutger Laurman"
echo "---"
echo "- Requires WP-CLI, make sure you install that first (http://wp-cli.org/)"
echo "- Check file for configurations"
echo "- Downloads, configures, installs WordPress, default theme and plugins"
echo "---"

# Configure defaults
DBUSER="development"
DBPASS="development"
EMAIL="support@lekkerduidelijk.nl"
WP_USER="rutger"
WP_PASS="rutger"
SITE_TITLE="Website"
SITE_URL_PREFIX="http://localhost/lekkerduidelijk"

function help() {
  echo "Usage: wpinstall.sh databasename"
  echo ""
}

if [ $1 ]
then
  echo "Starting WordPress installation..."
  echo ""
  echo "Using database name: '$1'"
  echo ""
  echo "- Downloading..."
  echo "-----------------------------------------"
  wp core download --locale=nl_NL
  echo ""
  echo "- Configuring..."
  echo "-----------------------------------------"
  wp core config --dbname=$1 --dbuser=development --dbpass=development
  echo ""
  echo "- Creating database..."
  echo "-----------------------------------------"
  wp db create
  echo ""
  echo "- Installing WordPress website..."
  echo "-----------------------------------------"
  wp core install --url=$SITE_URL_PREFIX/$1 --title=$SITE_TITLE --admin_email=$EMAIL --admin_name=$WP_USER --admin_password=$WP_PASS
  echo ""
  echo "- Installing plugin (1/2) Advanced Custom Fields..."
  echo "-----------------------------------------"
  wp plugin install advanced-custom-fields --activate
  echo ""
  echo "- Installing plugin (2/2) WordPress SEO..."
  echo "-----------------------------------------"
  wp plugin install wordpress-seo --activate
  echo ""
  echo "- Cloning LESS-WordPress theme into themes folder..."
  echo "-----------------------------------------"
  cd $(wp theme path)
  git clone git@github.com:lekkerduidelijk/less-wordpress.git
  echo ""
  echo "- Rename theme to $1..."
  echo "-----------------------------------------"
  mv less-wordpress $1
  cd $1
  echo ""
  echo "- Clean up .git folder"
  echo "-----------------------------------------"
  rm -rf .git/
  mv .gitignore ../../..
  mv .gitmodules ../../..
  echo ""
  echo "- Building theme with Grunt and Bower..."
  echo "-----------------------------------------"
  echo "Install node modules..."
  npm install --quiet
  echo "Install bower components..."
  bower install --quiet
  echo "Building theme assets with Grunt"
  grunt build
  cd ../../..
  echo ""
  echo "- Activating theme..."
  echo "-----------------------------------------"
  wp theme activate $1
  echo ""
  echo "- Initializing repository..."
  echo "-----------------------------------------"
  git init
  echo ""
  echo ""
  echo ""
  echo ">>>>>>>>>>>>>>>>>>>>>>> Done!"
  exit 1
else
  help;
fi