Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sets up a new Craft project in the ~/Sites folder with a bunch of plugins and boilerplate. Geared towards OSX users.
printf "\e[34mEnter name for this site\e[0m\n"
if [ -z "$DOMAIN" ];
whoami | USER=$1
mkdir -p $SITE
cd $SITE
printf "\e[33mInstalling Craft\e[0m\n"
# get latest craft build and unzip
if wget -O "$SITE/craft.tar.gz" ""; then
tar -xzf $SITE/craft.tar.gz craft public
rm $SITE/craft.tar.gz
printf "\e[31mFailed to download Craft, sorry!\e[0m\n"
# sort out the default files
rm $SITE/public/web.config
rm $SITE/craft/web.config
rm $SITE/public/htaccess
chmod -R 777 $SITE/craft/storage
chmod -R 777 $SITE/craft/config
# get craft boilerplate files
git clone $SITE/boilerplate
# jiggle them aroud
mv $SITE/boilerplate/.gitignore $SITE/.gitignore
mv $SITE/boilerplate/.htaccess $SITE/public/.htaccess
rm -fr $SITE/craft/templates
mv $SITE/boilerplate/craft/templates $SITE/craft/templates
mv $SITE/boilerplate/craft/config/db.php $SITE/craft/config/db.php
mv $SITE/boilerplate/craft/config/general.php $SITE/craft/config/general.php
mv $SITE/boilerplate/craft/config/routes.php $SITE/craft/config/routes.php
mv $SITE/boilerplate/craft/config/redactor/Article.json $SITE/craft/config/redactor/Article.json
rm -fr $SITE/boilerplate
# find and replace bits in files
sed -i.bak 's/database_name/'$DOMAIN'/g' $SITE/craft/config/db.php
rm $SITE/craft/config/db.php.bak
# get all the plugins we need
cd $SITE/craft/plugins
printf "\e[33mGetting plugins\e[0m\n"
# slugify
git clone $SITE/craft/plugins/slugify
rm -rf $SITE/craft/plugins/slugify/.git/
# anchors
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/anchors $SITE/craft/plugins/anchors
rm -rf $SITE/craft/plugins/tmp/
# sitemap
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/sitemap $SITE/craft/plugins/sitemap
rm -rf $SITE/craft/plugins/tmp/
# assetrev
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/assetrev $SITE/craft/plugins/assetrev
rm -rf $SITE/craft/plugins/tmp/
# supercooler
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/supercooler $SITE/craft/plugins/supercooler
rm -rf $SITE/craft/plugins/tmp/
# help
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/help $SITE/craft/plugins/help
rm -rf $SITE/craft/plugins/tmp/
# fetch
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/fetch $SITE/craft/plugins/fetch
rm -rf $SITE/craft/plugins/tmp/
# button box
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/buttonbox $SITE/craft/plugins/buttonbox
rm -rf $SITE/craft/plugins/tmp/
# pimp my matrix
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/pimpmymatrix $SITE/craft/plugins/pimpmymatrix
rm -rf $SITE/craft/plugins/tmp/
# toolbox
git clone $SITE/craft/plugins/tmp
mv $SITE/craft/plugins/tmp/toolbox $SITE/craft/plugins/toolbox
rm -rf $SITE/craft/plugins/tmp/
printf "\e[32mCraft Boilerplate installed!\e[0m\n"
# sort out database details
printf "\e[33mCreating local database.\e[0m\n"
mysql -uroot --password="PASSWORD" -e "create database $DOMAIN"
# virtual host
printf "\e[33mWe'll need your System password to sort out the vhost, please enter it now.\e[0m\n"
echo " $" | sudo tee -a /etc/hosts
echo "<VirtualHost *:80>" | sudo tee -a $FILE
echo " ServerName $" | sudo tee -a $FILE
echo " DocumentRoot $PUBLIC" | sudo tee -a $FILE
echo "</VirtualHost>" | sudo tee -a $FILE
sudo apachectl restart
sudo -k
printf "Launching http://$\n\n"
open "http://$"
printf "Now you will need to run the following things in the order specified:\n"
printf "1. Install the database.\n"
printf "2. Upgrade to Craft Pro.\n"
printf "3. Install the Supercooler plugin.\n"
printf "4. Go to http://$ and hit the red button.\n"
printf "5. If there were no errors and no WSOD then merrily uninstall the Supercooler plugin and go about your site build.\n\n"
printf "(If there were errors then ask Josh to help you)\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.