SilverStripe

Quickly Compile a SilverStripe website

When you're frequently building SilverStripe websites, you manage to create small efficiencies to make life a bit easier. To construct a SilverStripe website quickly, I have written a quick bash script that compiles the basic SilverStripe repositories into a install-ready git repository.


Create a new file called compile.sh with the code below. Then in your empty Git repository, run ./compile.sh install to build your SilverStripe site. Omitt the 'install' switch (ie ./compile.sh) if you are doing this on an existing SilverStripe repository that doesn't require installation (ie if you're deploying to a new machine or server).

compile.sh

#!/bin/bash

# Colors
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_MAGENTA=$ESC_SEQ"35;01m"
COL_CYAN=$ESC_SEQ"36;01m"

# Framework
echo -e $COL_YELLOW ADDING SILVERSTRIPE-FRAMEWORK SUBMODULE REPOSITORY $COL_RESET
git submodule add git@github.com:silverstripe/silverstripe-framework.git ./framework
echo

# CMS
echo -e $COL_YELLOW ADDING SILVERSTRIPE-CMS SUBMODULE REPOSITORY $COL_RESET
git submodule add git@github.com:silverstripe/silverstripe-cms.git ./cms
echo

# Installer
case "$1" in 'install')
echo -e $COL_YELLOW CLONING SILVERSTRIPE-INSTALLER REPOSITORY $COL_RESET
git clone git@github.com:silverstripe/silverstripe-installer.git ./install
mv ./install/* ./
echo
;;
esac

# assets folder
if [ ! -d "assets" ]; then
echo -e $COL_YELLOW CREATING ASSETS FOLDER $COL_RESET
mkdir assets
echo
fi
chmod 777 assets

# cache folder
if [ ! -d "silverstripe-cache" ]; then
echo -e $COL_YELLOW CREATING CACHE FOLDER $COL_RESET
mkdir silverstripe-cache
echo
fi
chmod 777 silverstripe-cache

# Complete
echo -e $COL_GREEN COMPILE COMPLETE $COL_RESET

You can also access this, and other codes on my GitHub Gist: https://gist.github.com/jaedb