Skip to content

Instantly share code, notes, and snippets.

@caruccio
Last active January 4, 2016 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caruccio/8609183 to your computer and use it in GitHub Desktop.
Save caruccio/8609183 to your computer and use it in GitHub Desktop.
Getup Cloud installer
#!/bin/bash
mesg() { echo -e "$(tput sgr0 && tput setaf 2)${*}$(tput sgr0)"; }
info() { echo -e "$(tput sgr0 && tput setaf 3)${*}$(tput sgr0)"; }
warn() { echo -e "$(tput sgr0 && tput setaf 1)${*}$(tput sgr0)"; }
echo
mesg ------------------------------
mesg "Este script instala e configura o RHC para utilizar na Getup Cloud."
warn "A senha do super usuário será solicitada em seguida."
read -n 1 -p "`info Pressione [ENTER] para continuar ou [CTRL]+C para cancelar...`"
mesg ------------------------------
sudo -k
sudo -l &>/dev/null
function install-git ()
{
if apt-get &>/dev/null; then
mesg "Detectado apt-get"
sudo apt-get install git-core
elif yum &>/dev/null; then
mesg "Detectado yum"
sudo yum install git
elif uname -v | grep -qi '^Darwin'; then
mesg "Detectado Mac OS X"
tmp_dir=`mktemp -t git -d`
git_url=https://git-osx-installer.googlecode.com/files/git-1.8.4.2-intel-universal-snow-leopard.dmg
wget $git_url -O $tmp_dir/${git_url##*/}
open -W $tmp_dir/${git_url##*/}
else
return 1
fi
}
if ! git --version &>/dev/null; then
read -p "`warn Não foi possivel encontrar o git. Deseja instalar agora? [S/n]` " -n 1 resp
if [ "$resp" = 's' -o "$resp" = 'S' -o -z "$resp" ]; then
if ! install-git; then
read -p "`warn 'Não foi possivel instalar o git. Deseja continuar mesmo assim? [S/n]'`" -n 1 resp
[ "$resp" = 's' -o "$resp" = 'S' -o -z "$resp" ] || exit 1
fi
fi
mesg ------------------------------
fi
echo
mesg "Iniciando instalacao do RHC. Aguarde alguns instantes..."
sudo gem install rhc
mesg "Instalacao finalizada. Preparando o setup..."
echo
read -p "`info 'Digite seu email na Getup:'` " email
read -p "`info 'Digite sua senha na Getup:'` " -s passwd
echo
mesg ------------------------------
rhc setup --server broker.getupcloud.com --create-token --clean --rhlogin "$email" --password "$passwd"
echo
mesg ------------------------------
mesg Para instruçoes de uso acesse: https://getup.zendesk.com/entries/38943987
mesg Instalação realizada com sucesso.
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment