Skip to content

Instantly share code, notes, and snippets.

@mlocher
Last active March 18, 2016 19:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save mlocher/f0f731dfa93c82d0fa86 to your computer and use it in GitHub Desktop.
Save mlocher/f0f731dfa93c82d0fa86 to your computer and use it in GitHub Desktop.
PhantomJS 2 on Codeship (Do not delete me, this is in use) 😄
#!/bin/bash
# Install a custom version 2 of PhantomJS, http://phantomjs.org/
#
# Include in your builds via
# \curl -sSL https://gist.githubusercontent.com/mlocher/f0f731dfa93c82d0fa86/raw/phantomjs2.sh | bash -s
PHANTOMJS_URL="https://s3.amazonaws.com/codeship.io/checkbot/binaries/phantomjs_2.0.1"
CACHED_DOWNLOAD="${HOME}/cache/phantomjs_2.0.1"
# official packages are now available, thus print an info message
echo -e "\e[36mOfficial PhantomJS 2 packages are now available from phantomjs.org\e[39m"
echo -e "\e[36mPlease consider switching to the main version of this script at\e[39m"
echo -e "\e[36mhttps://github.com/codeship/scripts/blob/master/packages/phantomjs.sh\e[39m"
# exit on the first error
set -e
# download and symlink version 2.0.1
wget --continue --output-document "${CACHED_DOWNLOAD}" "${PHANTOMJS_URL}"
chmod u+x "${CACHED_DOWNLOAD}"
ln -sf "${CACHED_DOWNLOAD}" "${HOME}/bin/phantomjs"
@davidstosik
Copy link

👍

@rafaelsales
Copy link

@mlocher
I changed this in my end to avoid downloading over and over again

# download and symlink version 2.0.1
if [[ `$CACHED_DOWNLOAD --version` != "2.0.1-development" ]]; then
  wget --continue --output-document "${CACHED_DOWNLOAD}" "${PHANTOMJS_URL}"
  chmod u+x "${CACHED_DOWNLOAD}"
  ln -sf "${CACHED_DOWNLOAD}" "${HOME}/bin/phantomjs"
fi

@mlocher
Copy link
Author

mlocher commented Sep 2, 2015

@rafaelsales

the script will cache the download in our dependency cache and --continue switches wget to resume a download. So if the file is already available it won't be re-downloaded, even without the if statement.

@mlocher
Copy link
Author

mlocher commented Mar 1, 2016

Official PhantomJS 2 binaries for Linux are now available on http://phantomjs.org/download.html, please switch to the original script at https://github.com/codeship/scripts/blob/master/packages/phantomjs.sh

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