install-acceptance-req.sh 2.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
#!/usr/bin/env bash

# Install all the requirements for running the
# acceptance test suite and the JavaScript
# unit test suite.
# 
# Requires 32-bit Ubuntu

# Exit if any commands return a non-zero status
set -e

sudo apt-get update

sudo apt-get install unzip

# Install xvfb
if [ -z `command -v xvfb` ]; then
    echo "Installing Xvfb..."
    sudo apt-get install -y xvfb

    # Install the xvfb upstart script
    sudo cat > /etc/init/xvfb.conf <<END
    description     "Xvfb X Server"
    start on (net-device-up
              and local-filesystems
              and runlevel [2345])
    stop on runlevel [016]
    exec /usr/bin/Xvfb :99 -screen 0 1024x768x24
END

    cat >> .bashrc <<END

    # Set the display to the virtual frame buffer (Xvfb)
    export DISPLAY=:99
END
else
    echo "Already installed; skipping."
fi

# Ensure that xvfb is running
sudo start xvfb 2> /dev/null || sudo restart xvfb 2> /dev/null || echo "Cannot start xvfb"

# Move to a temp directory so we can download things
cd /var/tmp

# Install Chrome
echo "Downloading Google Chrome..."
if [ -z `command -v google-chrome` ]; then
    wget --quiet https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb
    sudo dpkg -i google-chrome*.deb 2> /dev/null || true
    sudo apt-get -f -y install
else
    echo "Already installed; skipping."
fi

# Install ChromeDriver
echo "Installing ChromeDriver..."
if [ -z `command -v chromedriver` ]; then
    wget --quiet https://chromedriver.googlecode.com/files/chromedriver_linux32_2.3.zip
    unzip chromedriver_linux32_2.3.zip
    sudo mv chromedriver /usr/local/bin/chromedriver
    sudo chmod go+rx /usr/local/bin/chromedriver
else
    echo "Already installed; skipping."
fi

# Install Firefox
echo "Installing Firefox..."
sudo apt-get -y install firefox

# Install dbus (required for FF)
sudo apt-get -y install dbus-x11

# Install PhantomJS
echo "Installing PhantomJS..."
if [ -z `command -v phantomjs` ]; then
    wget --quiet "https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-i686.tar.bz2"
    tar -xjf phantomjs-1.9.1-linux-i686.tar.bz2
    sudo mv phantomjs-1.9.1-linux-i686/bin/phantomjs /usr/local/bin/phantomjs
else
    echo "Already installed; skipping."
fi

exit 0