Skip to content

Instantly share code, notes, and snippets.

@andrewfaria
Last active August 29, 2015 14:02
Show Gist options
  • Save andrewfaria/1f8589d5856cfbb38758 to your computer and use it in GitHub Desktop.
Save andrewfaria/1f8589d5856cfbb38758 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Selenium: http://www.chrisle.me/2013/08/running-headless-selenium-with-chrome/
# Fonts: http://alex.nederlof.com/blog/2012/11/19/installing-selenium-with-jenkins-on-ubuntu/
# Node: ppa:chris-lea/node.js
set -e
if [ -e /.installed ]; then
echo 'Already installed.'
else
echo ''
echo 'INSTALLING'
echo '----------'
# Add Google public key to apt
wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo apt-key add -
# Add Google to the apt-get source list
echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list
# Update app-get
apt-get update
# Install Java, Chrome, Xvfb, and unzip
apt-get -y install openjdk-7-jre google-chrome-stable xvfb unzip
# Download and copy the ChromeDriver to /usr/local/bin
cd /tmp
wget "https://chromedriver.googlecode.com/files/chromedriver_linux64_2.2.zip"
wget "https://selenium.googlecode.com/files/selenium-server-standalone-2.35.0.jar"
unzip chromedriver_linux64_2.2.zip
mv chromedriver /usr/local/bin
mv selenium-server-standalone-2.35.0.jar /usr/local/bin
# So that running `vagrant provision` doesn't redownload everything
touch /.installed
fi
# Start Xvfb, Chrome, and Selenium in the background
export DISPLAY=:10
cd /vagrant
echo "Starting Xvfb ..."
Xvfb :10 -screen 0 1366x768x24 -ac &
echo "Starting Google Chrome ..."
google-chrome --remote-debugging-port=9222 &
echo "Starting Selenium ..."
cd /usr/local/bin
nohup java -jar ./selenium-server-standalone-2.35.0.jar &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment