Last active
January 27, 2018 10:12
-
-
Save omargourari/600b997f5eb43b5b753b to your computer and use it in GitHub Desktop.
Bubble
This file contains 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
################################################################################ | |
# BUBBLE - Trellis/Bedrock/Sage automation script | |
# 1. Get the domain variable from the final website url | |
# 2. Check and install the bubble requirements | |
# 2.1 Check if Homebrew is installed | |
# 2.2 Check if Ansible is installed | |
# 2.3 Check if Virtualbox is installed | |
# 2.4 Check if Vagrant is installed | |
# 2.5 Install Vagrant plugins vagrant-bindfs and vagrant-hostmanager | |
# 2.6 Install hub | |
# 3. Clone Trellis, Bedrock, Sage and start ansible setup | |
# 4. Init local and remote repository | |
# 5. Setup local environment | |
# 5.1 Setup sage theme dependencies | |
# 6. Provision staging environment | |
# 6.1 Configure SSH keys | |
# 7. Launch the first deploy | |
################################################################################ | |
# | |
# 1. Get additional info | |
# | |
clear | |
sleep 0.5 | |
echo "\e[93m============================================" | |
echo "Bubble Install Script" | |
echo "============================================\e[0m" | |
echo "What's the website final domain?" | |
read site_domain | |
export site_domain | |
domain=$(echo $site_domain | awk -F\. '{print $1}') | |
echo "What's your Github username?" | |
read github_username | |
export github_username | |
echo "What's your staging server main IP?" | |
read staging_ip | |
export staging_ip | |
# | |
# 2. Check and install the bubble requirements | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Hi $(whoami) I'm going to check if your system have all the requirements (Brew, Ansible, Virtualbox, Vagrant, Vagrant-bindfs and Vagrant-hostmanager) installed properly." | |
printf "\n" | |
# | |
# 2.1 Check if Homebrew is installed | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Now I'm checking fi you have Homebrew installed and updated" | |
printf "\n" | |
which -s brew | |
if [[ $? != 0 ]] ; then | |
# Install Homebrew | |
# https://github.com/mxcl/homebrew/wiki/installation | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" | |
else | |
printf "\n" | |
echo "\e[93mOk, you have Homebrew installed\e[0m" | |
sleep 0.7 | |
printf "\n" | |
echo "Now I'm checking if your Homebrew is updated and if there're some errors with your formulas." | |
brew update && brew doctor | |
fi | |
# | |
# 2.2 Check if Ansible is installed | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Now I'm checking fi you have Ansible installed" | |
printf "\n" | |
which -s ansible || brew install ansible | |
# | |
# 2.3 Check if Virtualbox is installed | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Now I'm checking fi you have Virtualbox installed" | |
printf "\n" | |
ls /Applications/ | grep -i Virtualbox | |
if [[ $? != 0 ]] ; then | |
# Install Homebrew | |
# https://github.com/mxcl/homebrew/wiki/installation | |
brew cask install Virtualbox | |
else | |
printf "\n" | |
echo "\e[93mOk, you have Virtualbox installed\e[0m" | |
fi | |
# | |
# 2.4 Check if Vagrant is installed | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Now I'm checking fi you have Vagrnat installed" | |
printf "\n" | |
which -s vagrant | |
if [[ $? != 0 ]] ; then | |
# Install Homebrew | |
# https://github.com/mxcl/homebrew/wiki/installation | |
brew cask install vagrant | |
else | |
printf "\n" | |
echo "\e[93mOk, you have Vagrant installed\e[0m" | |
fi | |
# | |
# 2.5 Install Vagrant plugins vagrant-bindfs and vagrant-hostmanager | |
# | |
vagrant plugin install vagrant-bindfs | |
vagrant plugin install vagrant-hostmanager | |
# | |
# 2.6 Install Hub | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Now I'm checking fi you have Hub installed" | |
printf "\n" | |
which -s hub | |
if [[ $? != 0 ]] ; then | |
# Install Homebrew | |
# https://github.com/mxcl/homebrew/wiki/installation | |
brew install hub && eval "$(hub alias -s)" | |
else | |
printf "\n" | |
echo "\e[93mOk, you have Hub installed\e[0m" | |
fi | |
# | |
# 3. Clone Trellis, Bedrock, Sage and start ansible setup | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Now I'm cloning the last version of Trellis, Bedrock and Sage" | |
printf "\n" | |
git clone --depth=1 git@github.com:roots/trellis.git && rm -rf trellis/.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/sage && rm -rf site/web/app/themes/sage/.git && | |
cd trellis && ansible-galaxy install -r requirements.yml | |
# | |
# 4. Init local and remote repository | |
# | |
sleep 1 | |
printf "\n" | |
echo -e "Now I'm creating the local and remote repository of your project" | |
printf "\n" | |
cd .. | |
git init | |
git add --all | |
git commit -m "Initial commit" | |
git create $domain | |
git remote add origin git@github.com:$github_username/$domain.git | |
git push -u origin master | |
# | |
# 5. Setup local environment | |
# | |
# Edit trellis/group_vars/development/wordpress_sites.yml | |
# Edit vault.yml (with repo, branch, repo_subtree_path) | |
# vagrant up | |
# | |
# 5.1 Setup sage theme dependencies | |
# | |
# cd../site/web/app/themes/sage | |
# npm install | |
# bower install | |
# gulp | |
# | |
# 6. Provision staging environment | |
# | |
# cd ../../../../../trellis/group_vars/staging | |
# Edit wordpress_sites.yml | |
# Edit vault.yml | |
# cd ../../hosts | |
# Add server IP/hostnames staging | |
# | |
# 6.1 Configure SSH keys | |
# | |
# Modify group_vars/all/users.yml with ssh keys | |
# Add Github ssh keys to staging server | |
# Provision server with ansible-playbook server.yml -e env=staging | |
# | |
# 7. Launch the first deploy | |
# | |
# Run the first deploy ./deploy.sh staging $site_domain | |
# echo "Cleaning..." | |
#remove bash script | |
# rm bubble.sh | |
echo "\e[93m============================================" | |
echo "Bubble Installaton is complete" | |
echo "============================================\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment