Skip to content

Instantly share code, notes, and snippets.

@tobyl
Last active June 29, 2019 09:22
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tobyl/255b6225807b8b8db8f2 to your computer and use it in GitHub Desktop.
Save tobyl/255b6225807b8b8db8f2 to your computer and use it in GitHub Desktop.
Bash script to setup Bedrock, Trellis and Sage
#!/bin/bash
# set this variable - it will be used as both the root folder name and the theme name for sage
# no spaces - should not be a URL - I'm using 'my-site' or similar
SITENAME="your-site-name"
# Add BitBucket username/password to have a remote repo setup
BBUSER="YOUR-BB-USERNAME"
BBPASS="YOUR-BB-PASSWORD"
# save current pwd
cwd=$(pwd)/$SITENAME
# clone bedrock, trellis and sage
mkdir $SITENAME && cd $SITENAME
git clone --depth=1 git@github.com:roots/bedrock-ansible.git ansible && rm -rf ansible/.git
git clone --depth=1 git@github.com:roots/bedrock.git site && rm -rf site/.git
git clone --depth=1 git@github.com:roots/sage.git site/web/app/themes/$SITENAME && rm -rf site/web/app/themes/$SITENAME/.git
mv ansible/Vagrantfile .
# update ansible path
x="__dir__"
y="'ansible'"
sed -i -e "s/$x/$y/g" ./Vagrantfile
rm ./Vagrantfile-e
# add default theme
echo "define('WP_DEFAULT_THEME', '$SITENAME');" >> $cwd/site/config/application.php
# configure theme
cd $cwd/site/web/app/themes/$SITENAME
npm install
bower install
gulp
# add soil
cd $cwd/site && composer require roots/soil
# ansible roles
cd $cwd/ansible && ansible-galaxy install -r requirements.yml
# display some output
echo "New Trellis site '$SITENAME' installed in $cwd."
# setup new repo at BitBucket
curl --user $BBUSER:$BBPASS https://api.bitbucket.org/1.0/repositories/ --data name=$SITENAME
cd $cwd
git init
git remote add origin git@bitbucket.org:$BBUSER/$SITENAME.git
# display some output
echo "New Trellis site \033[0;31m$SITENAME\033[0m installed in \033[0;31m$cwd\033[0m."
# open atom
cd $cwd
atom .
@jasperf
Copy link

jasperf commented Oct 6, 2016

Why should the sitename not be a url? Forked it now as I love the idea and going through it now. Normally my project folder is site.com and in there I use site and trellis as folders for Bedrock and Sage. Perhaps I should add another variable for the root folder besides the one for the theme name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment