Created
November 23, 2015 14:05
-
-
Save yamadapc/365610aac02c553f21fd to your computer and use it in GitHub Desktop.
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
#!/bin/bash -e | |
if [ -t 1 ]; then | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
red=$(tput setaf 1) | |
blue=$(tput setaf 4) | |
gray=$(tput setaf 8) | |
light_white=$(tput setaf 15) | |
fi | |
function printf_info { | |
if [ -t 1 ]; then | |
printf "${light_white}${bold}$1${normal}" | |
else | |
printf "$1" | |
fi | |
} | |
function printf_error { | |
if [ -t 1 ]; then | |
printf "${red}${bold}$1${normal}" | |
else | |
printf "$1" | |
fi | |
} | |
function printf_question { | |
if [ -t 1 ]; then | |
printf "${blue}${bold}$1${normal}" | |
else | |
printf "$1" | |
fi | |
} | |
function prepare_fork_output { | |
if [ -t 1 ]; then | |
printf "${normal}${gray}" | |
fi | |
} | |
function fetch { | |
if [ ! $(which curl) ]; then | |
wget -O $2 $1 | |
else | |
curl -L $1 > $2 | |
fi | |
} | |
printf_info "> Checking if \`pacapt\` is installed\n" | |
if [ ! $(which pacapt) ]; then | |
printf_info ">> Going to install \`pacapt\`. A general package manager. Check: http://git.io/v4kbT\n" | |
prepare_fork_output | |
fetch https://github.com/icy/pacapt/raw/ng/pacapt /tmp/pacapt | |
printf_info ">> Installation script downloaded from http://git.io/vTniZ\n" | |
if [ -t 1 ]; then | |
printf_question ">> Would you like to open it on \`$EDITOR\`? (y/N) " | |
read -r | |
if [[ $REPLY =~ ^[yY]$ ]]; then | |
$EDITOR /tmp/pacapt | |
printf_question ">> Does it look safe? (Y/n) " | |
read -r | |
if [[ $REPLY =~ ^[nN]$ ]]; then | |
printf_error ">> Aborting...\n" | |
exit 1 | |
fi | |
fi | |
fi | |
prepare_fork_output | |
mv /tmp/pacapt /usr/local/bin/pacapt | |
chmod 755 /usr/local/bin/pacapt | |
ln -sv /usr/local/bin/pacapt /usr/local/bin/pacman || true | |
fi | |
printf_info "> Checking if \`git\` is installed\n" | |
if [ ! $(which git) ]; then | |
printf_info ">> Going to install \`git\`\n" | |
prepare_fork_output | |
pacapt -S git -y | |
fi | |
printf_info "> Checking if \`ruby\` is installed\n" | |
if [ ! $(which ruby) ]; then | |
printf_info ">> Going to install \`ruby\`\n" | |
prepare_fork_output | |
pacapt -S ruby -y | |
fi | |
printf_info "> Checking if \`gem\` is installed\n" | |
if [ ! $(which gem) ]; then | |
printf_error ">> Can't find \`gem\` and don't know how to install it\n" | |
exit 1 | |
fi | |
printf_info "> Checking if \`bundler\` is installed\n" | |
if [ ! $(which bundle) ]; then | |
prepare_fork_output | |
gem install bundler | |
fi | |
printf_info "> Checking if \`compass\` is installed\n" | |
if [ ! $(which compass) ]; then | |
prepare_fork_output | |
bundle install | |
fi | |
printf_info "> Checking if \`n\` is installed\n" | |
if [ ! $(which n) ]; then | |
if [ ! $(which make) ]; then | |
pacapt -S make -y | |
fi | |
printf_info ">> Installing \`node\` with \`n\`. See http://git.io/n-install-repo" | |
prepare_fork_output | |
fetch http://git.io/n-install /tmp/n | |
printf_info ">> Installation script downloaded from http://git.io/n-install\n" | |
if [ -t 1 ]; then | |
printf_question ">> Would you like to open it on \`$EDITOR\`? (y/N) " | |
read -r | |
if [[ $REPLY =~ ^[yY]$ ]]; then | |
$EDITOR /tmp/n | |
printf_question ">> Does it look safe? (Y/n) " | |
read -r | |
if [[ $REPLY =~ ^[nN]$ ]]; then | |
printf_error ">> Aborting...\n" | |
exit 1 | |
fi | |
fi | |
fi | |
bash /tmp/n | |
n latest | |
fi | |
printf_info "> Checking if \`node_modules\` present\n" | |
if [ ! -d node_modules ]; then | |
npm install | |
fi | |
printf_info "> Checking hosts file for toggl alias\n" | |
if ! cat /etc/hosts | grep "local.toggl.com" >/dev/null ; then | |
echo "local.toggl.com 127.0.0.1" >> /etc/hosts | |
fi | |
echo "------------------------------------------------------" | |
printf_info "> You should be good. Try running:\n" | |
echo "grunt serve" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment