Created
July 31, 2018 22:34
-
-
Save ericbaranowski/f8d8dfad77acb4ab1351b552fc301dd1 to your computer and use it in GitHub Desktop.
Bash script to setup Bedrock, Trellis and Sage
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 | |
# Trellis, Bedrock, & Sage project deployment automation | |
# setting this variable will make the root folder name, dev url and the theme name for sage | |
# created on 2016-07-14 by Toby Leftly @tobyl | |
# modified on 2016-04-29 by Daniel Willitzer @dwillitzer | |
# useage 'trellis-setup project-name' # use nospaces in 'project-name' | |
SITENAME=$1 | |
if [ -z $SITENAME ]; then | |
echo "Missing parameter SITENAME: $1 " | |
echo "Correct Usage: trellis-setup SITENAME" | |
exit | |
fi | |
# Add BitBucket username/password to have a remote repo setup | |
. ~/scripts/user.sh | |
if [[ ! -f ~/scripts/user.sh ]]; then | |
echo "No User file. Check your files for user.sh" | |
exit | |
fi | |
if [[ -f ~/scripts/user.sh ]]; then | |
if [[ -z "$BITBUCKET_USER" ]]; then | |
echo "Empty username & password. Why you Empty?"; | |
exit; | |
fi | |
fi | |
# save current pwd | |
cwd=$(pwd)/$SITENAME | |
# clone bedrock, trellis and sage | |
mkdir $SITENAME && cd $SITENAME | |
git clone --depth=1 [email protected]:roots/trellis.git && rm -rf trellis/.git | |
git clone --depth=1 [email protected]:roots/bedrock.git site && rm -rf site/.git | |
git clone --depth=1 [email protected]:roots/sage.git site/web/app/themes/$SITENAME && rm -rf site/web/app/themes/$SITENAME/.git | |
# mv trellis/Vagrantfile . | |
## causes site to break. | |
# # up\date trellis path | |
# x="__dir__" | |
# y="'trellis'" | |
# # sed -i -e "s/$x/$y/g" ./Vagrantfile | |
# # rm ./Vagrantfile-e | |
# sed -i -e "s/$x/$y/g" ./trellis/Vagrantfile | |
# rm ./trellis/Vagrantfile-e | |
# update local domain name | |
sed -i '' 's/example.com/'$SITENAME'.dev/g' $(find $cwd -name "*.yml"); | |
sed -i '' 's/example.dev/'$SITENAME'.dev/g' $(find $cwd -name "*.yml"); | |
# update vagrant ipaddress | |
sed -i '' 's/192.168.50.5/192.168.50.6/g' $(find $cwd -name "*.yml"); | |
# add default theme | |
echo "define('WP_DEFAULT_THEME', '$SITENAME.dev');" >> $cwd/site/config/application.php | |
# configure theme | |
cd $cwd/site/web/app/themes/$SITENAME | |
npm install | |
bower install | |
bower-update-all | |
gulp | |
# add soil | |
cd $cwd/site && composer require roots/soil | |
# ansible roles | |
cd $cwd/trellis && ansible-galaxy install -r requirements.yml | |
# setup new repo at BitBucket | |
# curl --user $BITBUCKET_USER:$BITBUCKET_PASS https://api.bitbucket.org/1.0/repositories/ --data name=$SITENAME | |
cd $cwd | |
git init | |
# git remote add origin [email protected]:$BITBUCKET_USER/$SITENAME.git | |
git add -A | |
git commit -m 'initial commit' | |
# active vagrant? | |
read -p "Want to activate Vagrant? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
cd $cwd/trellis | |
vagrant up | |
fi | |
# active IDE? | |
read -p "Want to activate IDE? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
cd $cwd | |
pstorm . | |
# open atom | |
fi | |
# display some output | |
echo "Your New Trellis site $SITENAME is installed in $cwd and available at $SITENAME.dev." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment