Last active
January 26, 2021 00:48
-
-
Save joshangell/8f54e2647a07c942fecd to your computer and use it in GitHub Desktop.
Sets up a new Craft project in the ~/Sites folder with a bunch of plugins and boilerplate. Geared towards OSX users.
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/sh | |
printf "\e[34mEnter name for this site\e[0m\n" | |
read DOMAIN | |
if [ -z "$DOMAIN" ]; | |
then | |
DOMAIN="${PWD##*/}" | |
fi | |
whoami | USER=$1 | |
SITE="/Users/$USER/Sites/$DOMAIN" | |
PUBLIC="/Users/$USER/Sites/$DOMAIN/public" | |
FILE="/etc/apache2/extra/httpd-vhosts.conf" | |
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" "http://buildwithcraft.com/latest.tar.gz?accept_license=yes"; then | |
tar -xzf $SITE/craft.tar.gz craft public | |
rm $SITE/craft.tar.gz | |
else | |
printf "\e[31mFailed to download Craft, sorry!\e[0m\n" | |
exit | |
fi | |
# 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 [email protected]:supercool/craft-boiler.git $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 [email protected]:boboldehampsink/slugify.git $SITE/craft/plugins/slugify | |
rm -rf $SITE/craft/plugins/slugify/.git/ | |
# anchors | |
git clone [email protected]:pixelandtonic/Anchors.git $SITE/craft/plugins/tmp | |
mv $SITE/craft/plugins/tmp/anchors $SITE/craft/plugins/anchors | |
rm -rf $SITE/craft/plugins/tmp/ | |
# sitemap | |
git clone [email protected]:supercool/Sitemap-Craft-Plugin.git $SITE/craft/plugins/tmp | |
mv $SITE/craft/plugins/tmp/sitemap $SITE/craft/plugins/sitemap | |
rm -rf $SITE/craft/plugins/tmp/ | |
# assetrev | |
git clone [email protected]:weareclub/craft-asset-rev.git $SITE/craft/plugins/tmp | |
mv $SITE/craft/plugins/tmp/assetrev $SITE/craft/plugins/assetrev | |
rm -rf $SITE/craft/plugins/tmp/ | |
# supercooler | |
git clone [email protected]:supercool/craft-supercooler.git $SITE/craft/plugins/tmp | |
mv $SITE/craft/plugins/tmp/supercooler $SITE/craft/plugins/supercooler | |
rm -rf $SITE/craft/plugins/tmp/ | |
# help | |
git clone [email protected]:supercool/craft-help.git $SITE/craft/plugins/tmp | |
mv $SITE/craft/plugins/tmp/help $SITE/craft/plugins/help | |
rm -rf $SITE/craft/plugins/tmp/ | |
# fetch | |
git clone [email protected]:supercool/craft-fetch.git $SITE/craft/plugins/tmp | |
mv $SITE/craft/plugins/tmp/fetch $SITE/craft/plugins/fetch | |
rm -rf $SITE/craft/plugins/tmp/ | |
# button box | |
git clone [email protected]:supercool/Button-Box.git $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 [email protected]:supercool/Pimp-My-Matrix.git $SITE/craft/plugins/tmp | |
mv $SITE/craft/plugins/tmp/pimpmymatrix $SITE/craft/plugins/pimpmymatrix | |
rm -rf $SITE/craft/plugins/tmp/ | |
# toolbox | |
git clone [email protected]:supercool/craft-toolbox.git $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 "127.0.0.1 $DOMAIN.craft.dev" | sudo tee -a /etc/hosts | |
echo "<VirtualHost *:80>" | sudo tee -a $FILE | |
echo " ServerName $DOMAIN.craft.dev" | 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://$DOMAIN.craft.dev\n\n" | |
open "http://$DOMAIN.craft.dev/admin" | |
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://$DOMAIN.craft.dev/admin/supercooler 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" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment