Skip to content

Instantly share code, notes, and snippets.

@bmadigan
Created January 4, 2016 19:55
Show Gist options
  • Save bmadigan/2b03b29e42cde8d3952b to your computer and use it in GitHub Desktop.
Save bmadigan/2b03b29e42cde8d3952b to your computer and use it in GitHub Desktop.
Shell File To Install Bedrock, Sage Theme and initialize app, composer install and initialize GIT
#!/bin/bash
function coloredEcho(){
local exp=$1;
local color=$2;
if ! [[ $color =~ '^[0-9]$' ]] ; then
case $(echo $color | tr '[:upper:]' '[:lower:]') in
black) color=0 ;;
red) color=1 ;;
green) color=2 ;;
yellow) color=3 ;;
blue) color=4 ;;
magenta) color=5 ;;
cyan) color=6 ;;
white|*) color=7 ;; # white or invalid color
esac
fi
tput setaf $color;
echo $exp;
tput sgr0;
}
###############################################################################
# WP Install Script Script v0.2.0
# By Brad Madigan ([email protected])
###############################################################################
mkdir -p tmp
echo "==============================================="
echo "Cavera.ca WordPress / Bedrock Install Script"
echo "==============================================="
echo ''
coloredEcho "Would you like to install the lastest version of Bedrock in this directory?"
read -p "[y/N]" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
echo ''
echo ''
coloredEcho 'Downloading and installing the latest version of Bedrock...' green
echo ''
curl -L https://github.com/roots/bedrock/archive/master.zip? -o tmp/WP-Bedrock.zip
unzip tmp/WP-Bedrock.zip
rm -rf tmp
# Move all files from the new bedrock-master into the parent
cd bedrock-master
mv * ../
cd ..
rm -rf bedrock-master
coloredEcho "Bedrock Wordpress site has been created!" magenta
echo ''
###############################################################################
# Install Sage?
###############################################################################
coloredEcho "Would you like to install the Sage Starter Theme? (y/n)" white
read -e setupSage
if [ "$setupSage" == y ] ; then
echo ''
coloredEcho 'Downloading and installing Sage Theme...' green
echo ''
mkdir -p tmp
curl -L https://github.com/roots/sage/archive/master.zip? -o tmp/sage.zip
unzip tmp/sage.zip
rm -rf tmp
# move folder to themes folder
mv sage-master web/app/themes/sage
echo ''
coloredEcho "Copied sage to the themes folder" magenta
fi
###############################################################################
# Run Composer Install
###############################################################################
echo ''
coloredEcho "Running Composer installation (this may take a few moments) ..." green
echo ''
composer install
echo ''
# Get the database name
coloredEcho "What is the name of the database?" white
read -e dbName
coloredEcho "What is the full url for local development? (eg. http://example.dev)" white
read -e urlHome
cat >.env <<EOL
DB_HOST=localhost
DB_NAME=$dbName
DB_USER=forge
DB_PASS=secret
WP_ENV=development
WP_HOME=$urlHome
WP_SITEURL=$urlHome/wp
EOL
cp .env .env.example
echo ''
coloredEcho '- Created .env and .env.example' magenta
# Create .gitignore
touch .gitignore
echo '.env' >> .gitignore
echo '/vendor/' >> .gitignore
echo ''
coloredEcho 'Added .env and /vendor folder to the .gitignore' magenta
echo ''
git init
git add .
git commit -m 'Initial commit from CLI'
coloredEcho 'Initialized and Commited Your First Git Commmit!' magenta
###############################################################################
# Script is done and give some instructions!
###############################################################################
echo ''
coloredEcho 'EXCELLENT!! WE ARE DONE !!!' green
echo ''
coloredEcho 'Next steps:' white
coloredEcho '=================================' yellow
coloredEcho ' - Setup Homestead Account' yellow
coloredEcho ' - Make sure and use the $urlHome ' yellow
coloredEcho ' - Make sure and use the $dbName database name ' yellow
coloredEcho '$> Edit ~/.homestead/Homestead.yml' yellow
coloredEcho '=================================' yellow
coloredEcho 'Happy Coding!' white
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment