Skip to content

Instantly share code, notes, and snippets.

@kolosek
Last active April 24, 2017 15:30
Show Gist options
  • Save kolosek/4eb8ef8142262768e12ba42268184424 to your computer and use it in GitHub Desktop.
Save kolosek/4eb8ef8142262768e12ba42268184424 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Install a custom version of PhantomJS, http://phantomjs.org/
#
# If you run into any rate limiting issues from bitbucket, put the download
# file(s) into your own server and point to the location via the PHANTOMJS_HOST
# environment variable.
#
# Add at least the following environment variables to your project configuration
# (otherwise the defaults below will be used).
# * PHANTOMJS_VERSION - Specify the version of PhantomJS
# * PHANTOMJS_HOST - Optional, specify the download location for the archive
#
# For versions 1.9.7, 1.9.8 and 2.1.1 you can also use a Codeship provided mirror
# by setting the PHANTOMJS_HOST variable to https://s3.amazonaws.com/codeship-packages
#
# export PHANTOMJS_HOST="https://s3.amazonaws.com/codeship-packages"
#
# Include in your builds via
# \curl -sSL https://gist.githubusercontent.com/kolosek/4eb8ef8142262768e12ba42268184424/raw/2463784fa88aa324dfafee118ae559ac93bf5eed/phantomjs-codeship.sh | bash -s
PHANTOMJS_VERSION=${PHANTOMJS_VERSION:="1.9.8"}
PHANTOMJS_HOST=${PHANTOMJS_HOST:="https://bitbucket.org/ariya/phantomjs/downloads"}
set -e
CACHED_DOWNLOAD="${HOME}/cache/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2"
# clean old version and setup directories
rm -rf ~/.phantomjs
mkdir ~/.phantomjs
wget --continue --output-document "${CACHED_DOWNLOAD}" "${PHANTOMJS_HOST}/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2"
tar -xaf "${CACHED_DOWNLOAD}" --strip-components=1 --directory "${HOME}/.phantomjs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment