Skip to content

Instantly share code, notes, and snippets.

@strund3r
Created December 5, 2016 16:52
Show Gist options
  • Save strund3r/c6a2d350851d93b9d5124df5d77f80ed to your computer and use it in GitHub Desktop.
Save strund3r/c6a2d350851d93b9d5124df5d77f80ed to your computer and use it in GitHub Desktop.
#!/bin/bash
# carregando configurações via params
for i in $*
do
if [[ "$i" == '-y' || "$i" == '-Y' ]] ; then
all_alowed=true
fi
done
if ! [ $all_alowed ] ; then
read -p 'Deseja aceitar a instalação de todos as aplicações que estão presentes? (Y/N) ' alowed_install
if [[ "$alowed_install" == "Y" || "$alowed_install" == "y" ]] ; then
all_alowed=true
fi
fi
echo '--- Rodando SoftWare Update & Upgrade'
echo ''
sudo apt update && sudo apt upgrade
echo ''
if ! [ $all_alowed ] ; then read -p 'Deseja instalar o Unity Tweak Tool? (Y/N) ' install_chrome ; fi
if [[ $all_alowed || "$install_chrome" != "N" && "$install_chrome" != "n" ]] ; then
echo '--- Unity Tweak Tool'
echo ''
echo '-- Instalando o Unity Tweak Tool'
sudo apt-get install unity-tweak-tool
echo ''
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja instalar o Google Chrome? (Y/N) ' install_chrome ; fi
if [[ $all_alowed || "$install_chrome" != "N" && "$install_chrome" != "n" ]] ; then
echo '--- Google Chrome'
echo ''
echo '-- Atualizando Sistema'
sudo apt update && sudo apt upgrade
echo ''
echo '-- Instalando gdebi'
sudo apt install gdebi
echo ''
echo '-- Baixando o Google Chrome'
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
echo ''
echo '-- Instalando o Google Chrome'
sudo gdebi google-chrome-stable_current_amd64.deb
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja instalar o Docky - Mackbook Menu? (Y/N) ' install_docky ; fi
if [[ $all_alowed || "$install_docky" != "N" && "$install_docky" != "n" ]] ; then
echo '--- Docky - Mackbook Menu'
echo ''
echo '-- Instalando Docky'
sudo apt install docky
echo ''
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja instalar o Git? (Y/N) ' install_git ; fi
if [[ $all_alowed || "$install_git" != "N" && "$install_git" != "n" ]] ; then
echo '--- Git'
echo ''
echo '-- Instalando Git'
sudo apt install git
sudo apt install xclip
echo ''
echo '-- Configurando Nome e email do git'
read -p "Digite seu nome: " git_name
git config --global user.name "$git_name"
read -p "Digite seu email: " git_email
git config --global user.email "$git_email"
echo ''
echo '-- Configurando SSH key git'
ssh-keygen -t rsa -b 4096 -C "$git_email"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
xclip -sel clip < ~/.ssh/id_rsa.pub
echo ''
echo '-- Código gerado e copiado, adicione com CTRL+V sua ssh key no seu github'
sh -c 'google-chrome https://github.com/settings/keys'
read -p 'Digite [ENTER] para continuar caso já tenha adicionado '
echo ''
echo '-- Configurando para não pedir senha'
ssh -T [email protected]
echo ''
echo '-- Configurando Atalhos'
echo ''
echo '- checkout => co'
git config --global alias.co checkout
echo '- branch => br'
git config --global alias.br branch
echo '- commit => ci'
git config --global alias.ci commit
echo '- status => st'
git config --global alias.st status
echo ''
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja instalar o rvm? (Y/N) ' install_rvm ; fi
if [[ $all_alowed || "$install_rvm" != "N" && "$install_rvm" != "n" ]] ; then
echo '--- RVM 2.0'
echo ''
echo '-- Atualiznado Sistema e Baixando dependencias'
sudo apt update
sudo apt install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
echo ''
echo '-- Instalando RVM'
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.0.0-p648
rvm use 2.0.0-p648 --default
sudo gem install bundler
echo ''
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja instalar o Albert? (Y/N) ' install_albert ; fi
if [[ $all_alowed || "$install_albert" != "N" && "$install_albert" != "n" ]] ; then
echo '--- Albert'
echo ''
echo '-- Instalando Albert'
sudo add-apt-repository ppa:noobslab/macbuntu
sudo apt update
sudo apt install albert
echo ''
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja instalar docker? (Y/N) ' install_docker ; fi
if [[ $all_alowed || "$install_docker" != "N" && "$install_docker" != "n" ]] ; then
echo '--- Docker'
echo ''
echo '-- Instalando Docker'
sudo apt update
sudo apt install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install docker-engine
sudo service docker start
apt-cache policy docker-engine
sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
echo ''
echo '-- Configurando sudo do Docker'
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo usermod -aG docker ${USER}
sudo service docker restart
newgrp docker
echo ''
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja instalar docker compose? (Y/N) ' install_docker_compose ; fi
if [[ $all_alowed || "$install_docker_compose" != "N" && "$install_docker_compose" != "n" ]] ; then
echo '--- Docker Compose'
echo ''
echo '-- Instalando Docker'
sudo curl -L https://github.com/docker/compose/releases/download/1.4.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo ''
echo ''
echo '--- Rodando SoftWare Update'
echo ''
sudo apt update
echo ''
fi
if ! [ $all_alowed ] ; then read -p 'Deseja baixar e configurar o repositório do ERP? (Y/N) ' download_repo ; fi
if [[ $all_alowed || "$download_repo" != "N" && "$download_repo" != "n" ]] ; then
echo '--- Repositório SeuCondominio'
echo ''
echo '-- Baixando Repositório'
mkdir ~/workspace
git clone [email protected]:denoww/seucondominio.git ~/workspace/seucondominio
echo ''
echo '-- Configurando Repositório'
cp ~/workspace/seucondominio/gitignore_sample ~/workspace/seucondominio/.gitignore
cp ~/workspace/seucondominio/config/application_sample.yml ~/workspace/seucondominio/config/application.yml
cp ~/workspace/seucondominio/Dockerfile_sample ~/workspace/seucondominio/Dockerfile
cp ~/workspace/seucondominio/docker-compose_sample.yml ~/workspace/seucondominio/docker-compose.yml
echo ''
echo '-- Preparando ambiente ERP'
sudo apt install libpq-dev
sudo gem install bundler
sh -c 'cd ~/workspace/seucondominio/ && bundle install'
echo ''
echo '-- Criar imagem do Docker'
sh -c 'cd ~/workspace/seucondominio/ && docker build .'
sh -c 'cd ~/workspace/seucondominio/ && docker-compose build'
echo ''
echo '-- Criando e adicionando aliases'
echo -e "# docker" >> ~/.bash_aliases
echo -e "alias sccd='cd ~/workspace/seucondominio'" >> ~/.bash_aliases
echo -e "alias scdockerrun='sccd; docker-compose run'" >> ~/.bash_aliases
echo -e "alias scrails='sccd; scdockerrun web rails'" >> ~/.bash_aliases
echo -e "alias scrake='sccd; scdockerrun web rake'" >> ~/.bash_aliases
echo -e "alias scs='sccd; scdockerrun web rm /erp/tmp/pids/server.pid; docker-compose up --force-recreate'" >> ~/.bash_aliases
echo -e "alias scc='sccd; scrails c'" >> ~/.bash_aliases
echo -e "alias scdbconsole='sccd; scrails dbconsole'" >> ~/.bash_aliases
echo -e "alias scpsql='scpsql'" >> ~/.bash_aliases
echo -e "alias scg='sccd; scrails g'" >> ~/.bash_aliases
echo -e "alias scd='sccd; scrails d'" >> ~/.bash_aliases
echo -e "alias scseed='sccd; scrake sc:seed'" >> ~/.bash_aliases
echo -e "alias scdrop='sccd; scrake db:drop; scrake db:mongoid:drop'" >> ~/.bash_aliases
echo -e "alias scmigrate='sccd; scrake sc:db:migrate_with_dependents'" >> ~/.bash_aliases
echo -e "alias scrollback='sccd; scrake sc:db:rollback_with_dependents'" >> ~/.bash_aliases
echo -e "alias scsetupdependents='sccd; scrake sc:db:pg:setup_dependents'" >> ~/.bash_aliases
echo -e "alias scmigrationstatus='sccd; scrake db:migrate:status'" >> ~/.bash_aliases
echo -e "alias scbundleinstall='sccd; bundle install; scdockerrun web bundle install; scdockerrun worker bundle install'" >> ~/.bash_aliases
echo -e "# alias scbundleinstall='sccd; bundle install; scdockerrun bundle bundle install; scdockerrun web bundle install; scdockerrun worker bundle install'" >> ~/.bash_aliases
echo -e "# alias scbundleinstall='sccd; scdockerrun bundle bundle install'" >> ~/.bash_aliases
echo -e "alias scredis='sccd; scdockerrun redis redis-cli'" >> ~/.bash_aliases
echo -e "" >> ~/.bash_aliases
echo -e "# test" >> ~/.bash_aliases
echo -e "alias sctestc='sccd; scrails c test'" >> ~/.bash_aliases
echo -e "alias sctestmigrate='sccd; scrake db:migrate RAILS_ENV=test'" >> ~/.bash_aliases
echo -e "alias sctestseed='sccd; scrake sc:seed RAILS_ENV=test'" >> ~/.bash_aliases
echo -e "alias sctestdrop='sccd; scrake db:drop RAILS_ENV=test; scrake db:mongoid:drop RAILS_ENV=test'" >> ~/.bash_aliases
echo -e "" >> ~/.bash_aliases
echo -e "# rspec" >> ~/.bash_aliases
echo -e "alias scrspec='sccd; scdockerrun web rspec --format documentation'" >> ~/.bash_aliases
echo -e "" >> ~/.bash_aliases
echo -e "# staging" >> ~/.bash_aliases
echo -e "alias scstagingc='heroku run rails c -a staging-seucondominio'" >> ~/.bash_aliases
echo -e "alias scstagingmigrate='heroku run rake sc:db:migrate_with_dependents -a staging-seucondominio'" >> ~/.bash_aliases
echo -e "alias scstagingmigrationstatus='heroku run rake db:migrate:status -a staging-seucondominio'" >> ~/.bash_aliases
echo -e "alias scstagingrollback='heroku run rake sc:db:rollback_with_dependents -a staging-seucondominio'" >> ~/.bash_aliases
echo -e "alias scstaginglogs='heroku logs -t -a staging-seucondominio'" >> ~/.bash_aliases
echo -e "alias scstagingrestart='heroku restart -a staging-seucondominio'" >> ~/.bash_aliases
echo -e "alias scstagingbash='heroku run bash -a staging-seucondominio'" >> ~/.bash_aliases
echo -e "" >> ~/.bash_aliases
echo -e "# production" >> ~/.bash_aliases
echo -e "alias scproductionssh='cx ssh -s 'seucondominio' -e production Anakin'" >> ~/.bash_aliases
echo -e "" >> ~/.bash_aliases
echo -e "# backup production" >> ~/.bash_aliases
echo -e "alias scbackupssh='cx ssh -s 'seucondominio-backup' -e production Anteater'" >> ~/.bash_aliases
echo ''
echo '-- Config Development'
sh -c 'cd ~/workspace/seucondominio; bundle install; docker-compose run web bundle install; docker-compose run worker bundle install'
sh -c 'cd ~/workspace/seucondominio; docker-compose run web rake sc:seed'
sh -c 'cd ~/workspace/seucondominio; scdockerrun web rm /erp/tmp/pids/server.pid; docker-compose up --force-recreate'
sh -c 'google-chrome http://localhost:3000'
echo ''
echo ''
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment