Last active
August 28, 2016 11:34
-
-
Save dinhnv/6eee21ad7677aa93ad7be3385c0b031c to your computer and use it in GitHub Desktop.
Use for CI remote call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# script install phantomjs for ci automatically build & test | |
# \curl -sSL https://gist.githubusercontent.com/dinhnv/6eee21ad7677aa93ad7be3385c0b031c/raw/install_phantomjs.sh | bash -s | |
set -euo pipefail | |
IFS=$'\n\t' | |
# workaround for gitlab cache | |
WORK_DIR=`pwd` | |
CACHE_DIR="${WORK_DIR}/.cache" | |
[ -d ${CACHE_DIR} ] || mkdir -p ${CACHE_DIR} | |
# apt-get install build-essential chrpath libssl-dev libxft-dev -y | |
# apt-get install libfreetype6 libfreetype6-dev -y | |
# apt-get install libfontconfig1 libfontconfig1-dev -y | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" 1>&2 | |
echo "sudo $0 $*" 1>&2 | |
exit 1 | |
fi | |
apt-get install fontconfig | |
ARCH=$(uname -m) | |
if ! [ $ARCH = "x86_64" ]; then | |
$ARCH="i686" | |
fi | |
# phantomjs | |
PHANTOMJS_VERSION=phantomjs-${PHANTOMJS_VERSION:="2.1.1"}-linux-${ARCH} | |
PHANTOMJS_HOST=${PHANTOMJS_HOST:="https://s3.amazonaws.com/codeship-packages"} | |
PT_DIR="${CACHE_DIR}/phantomjs" | |
[ -d ${PT_DIR} ] || mkdir -p ${PT_DIR} | |
PT_CACHE_DOWNLOAD="${PT_DIR}/${PHANTOMJS_VERSION}.tar.bz2" | |
PT_OUTPUT_DIR="${PT_DIR}/${PHANTOMJS_VERSION}" | |
echo "check directory $PT_OUTPUT_DIR" | |
if [ -d "${PT_OUTPUT_DIR}" ]; then | |
echo 'Already install phantomjs' | |
else | |
echo 'Download new phantomjs' | |
mkdir $PT_OUTPUT_DIR | |
wget -c --output-document "${PT_CACHE_DOWNLOAD}" "${PHANTOMJS_HOST}/${PHANTOMJS_VERSION}.tar.bz2" | |
tar -xaf "${PT_CACHE_DOWNLOAD}" --strip-components=1 --directory "${PT_OUTPUT_DIR}" | |
fi | |
ln -sf "${PT_OUTPUT_DIR}/bin/phantomjs" /usr/local/bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment