Last active
December 28, 2015 18:59
-
-
Save bigandy/7547227 to your computer and use it in GitHub Desktop.
WordPress Installation Script
This file contains hidden or 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 | |
function newSite { | |
local appdir="/Applications/XAMPP/htdocs/$1" | |
local sourcedir="/Applications/XAMPP/htdocs/source" | |
local author="Andrew JD Hudson" | |
local themedir="/Applications/XAMPP/htdocs/$1/content/themes/$1" | |
local starterTheme="es-theme" | |
local httpd_vhosts="/Applications/XAMPP/etc/extra/httpd-vhosts.conf" | |
local git="ssh://[email protected]/bigandy" | |
if [ ! -d $appdir ] | |
then | |
mkdir -p $appdir/wp | |
mkdir -p $appdir/content/themes/$1 | |
# Copy Directories | |
cp -rf $sourcedir/wp/ $appdir/wp | |
cp -rf $sourcedir/$starterTheme/ $appdir/content/themes/$1 | |
# Copy files | |
cp $sourcedir/{wp-config,index}.php $appdir | |
cp $sourcedir/source.sublime-project $appdir/$1.sublime-project | |
cp $sourcedir/source.sublime-workspace $appdir/$1.sublime-workspace | |
# change folder url in sublime-project | |
sed -i '' 's/source/'$1'/' $appdir/$1.sublime-project | |
# Remove the git repos from the original source folders | |
rm -rf $appdir/content/themes/$1/.git/ | |
rm -rf $appdir/wp/.git/ | |
# swap %%THEME_NAME%% with $1 in sass file | |
# $appdir/content/themes/$1/sass/style.sass | |
sed -i '' 's/Starter Theme/'$1'/' $appdir/content/themes/$1/sass/style.sass | |
sed -i '' 's/odo/'$1'/' $appdir/wp-config.php | |
# Create the initial stylesheet | |
cd $appdir/content/themes/$1 && grunt sass | |
if [ ! $2 ] | |
then | |
$2 = $1 | |
fi | |
# Git init, add, commit, set origin, push to origin | |
cd $appdir/content/themes/$1 && git init && git add -A && git commit -m "initial commit of theme files" && git remote add origin $git/$2.git && git push -u origin --all | |
# Add folder and url to httpd-vhosts.conf | |
echo ' | |
<VirtualHost *:80> | |
ServerName '$1'.local | |
DocumentRoot "'$appdir'" | |
</VirtualHost>' | sudo tee -a $httpd_vhosts > /dev/null | |
# /etc/hosts set up | |
sudo sed -ie 's/^127.0.0.1 localhost.*$/& '$1'.local/g' /etc/hosts | |
# restart apache so the above changes to httpd-vhosts.conf will take effect | |
sudo apachectl restart | |
# Create DB | |
# mysql -u root -e "CREATE DATABASE IF NOT EXISTS $1_db;"; exit; | |
# | |
# subl $appdir/ | |
# Open Project in Sublime Text 3 | |
cd $appdir && subl --project ${1}.sublime-project | |
# TODO | |
# 1. Plugins - how to compile a list of plugins in a folder, or import from a list? see bulk plugin installer plugin (http://wordpress.org/plugins/bulk-plugin-installation/) | |
# 2. Import test DB with all installs from test.sql | |
else | |
echo "Please choose a name that is not $1" | |
fi | |
} | |
newSite $1 $2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assumes use of:
This file:
Use
If you want the git repo to be different add a second parameter e.g.