Skip to content

Instantly share code, notes, and snippets.

@bigandy
Last active August 29, 2015 14:14
Show Gist options
  • Save bigandy/ecf1c94f154024ba8ffc to your computer and use it in GitHub Desktop.
Save bigandy/ecf1c94f154024ba8ffc to your computer and use it in GitHub Desktop.
New WordPress build script
#!/bin/bash
function newsite {
local email="andrew@electricstudio.co.uk"
local appdir="/Users/andrew/Sites/$1"
local httpd_vhosts="/etc/apache2/extra/httpd-vhosts.conf"
# local input=$1
# local size=${#input}
# local max="8"
local basedir=$PWD
# # This checks to see if the input is greater than 8 characters, then if so keeps the first 8 characters
# if [ $size -le $max ]
# then
# $dbprefix=$input
# else
# $dbprefix=${input:0:$max}
# fi
mkdir $1 && cd $1
wp core download
wp core config --dbname="$1" --dbuser=root --dbhost=localhost
wp db create
wp core install --url="http://$1.dev" --title="$1" --admin_user="ElectricStudio" --admin_password="Ketchup123$" --admin_email=$email
cd wp-content/themes
git clone git@bitbucket.org:electricstudio/boilerplate.git $1 --depth=1
cd $1
# npm install && bower install
rm -rf .git
wp theme activate $1
# wp plugin delete hello
cd $basedir && cp gravityforms-develop.zip $appdir
cd $appdir
wp plugin install gravityforms-develop.zip --activate
# gulp sass && gulp js && gulp sprites
# cd .. && rm -rf twenty*
## Part 2 the virtual Hosts
# Add folder and url to httpd-vhosts.conf
echo '
<VirtualHost *:80>
ServerName '$1'.dev
DocumentRoot "'$appdir'"
</VirtualHost>' | sudo tee -a $httpd_vhosts > /dev/null
# /etc/hosts set up
sudo sed -ie 's/^127.0.0.1 localhost.*$/& '$1'.dev/g' /etc/hosts
# restart apache so the above changes to httpd-vhosts.conf will take effect
sudo apachectl restart
cd $1 && subl .
open http://$1.dev
}
newsite $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment