Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Example frontend tools setup shell script (I use it with Vagrant and a Linux box). Includes Java, Node, PhantomJS, sitespeed.io, Gunt, Bower and Compass
#!/bin/bash
# Vars
java="java"
xsltproc="xsltproc"
node="node"
phantomjs="phantomjs"
grunt="grunt"
bower="bower"
compass="compass"
sitespeed="sitespeed.io"
# Function to check if command available
# 0 = true (think of 0 as no errors)
# 1 = false (think of 1 as 1 error)
function isnotavailable() {
if ! type "$1" > /dev/null;
then
return 0
else
return 1
fi
}
# Java
if isnotavailable "$java"
then
echo "--- Installing Java ---"
sudo apt-get update
sudo apt-get -y install default-jre
else
echo -e "\xe2\x9c\x94 Java already installed"
fi
# XSLTProc
if isnotavailable "$xsltproc"
then
echo "--- Installing XSLTProc ---"
sudo apt-get update
sudo apt-get -y install xsltproc
else
echo -e "\xe2\x9c\x94 XSLTProc already installed"
fi
# NodeJS
if isnotavailable "$node"
then
echo "--- Installing NodeJS ---"
sudo apt-get update
sudo apt-get -y install software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get -y install python-software-properties python g++ make nodejs
else
echo -e "\xe2\x9c\x94 NodeJS already installed"
fi
# PhantomJS
if isnotavailable "$phantomjs"
then
echo "--- Installing PhantomJS ---"
(cd /usr/local/share; sudo wget -q https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2; tar xjf phantomjs-1.9.0-linux-x86_64.tar.bz2;)
(sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/bin/phantomjs)
else
echo -e "\xe2\x9c\x94 PhantomJS already installed"
fi
# sitespeed.io
if isnotavailable "$sitespeed"
then
echo "--- Installing sitespeed.io ---"
(cd /usr/local/share; git clone https://github.com/sitespeedio/sitespeed.io.git)
(sudo ln -s /usr/local/share/sitespeed.io/bin/sitespeed.io /usr/local/bin/sitespeed.io; sudo ln -s /usr/local/share/sitespeed.io/bin/sitespeed.io /usr/bin/sitespeed.io;)
else
echo -e "\xe2\x9c\x94 sitespeed.io already installed"
fi
# Grunt
if isnotavailable "$grunt"
then
echo "--- Installing grunt-cli ---"
npm install -g grunt-cli
else
echo -e "\xe2\x9c\x94 grunt-cli already installed"
fi
# Bower
if isnotavailable "$bower"
then
echo "--- Installing Bower ---"
npm install -g bower
else
echo -e "\xe2\x9c\x94 Bower already installed"
fi
# Compass
if isnotavailable "$compass"
then
echo "--- Installing Compass ---"
gem install compass
else
echo -e "\xe2\x9c\x94 Compass already installed"
fi
Owner

matt-bailey commented Jul 18, 2014

I use this in conjunction with my Vagrant boilerplate: https://github.com/gpmd/vagrant-puppet-boilerplate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment