Created
August 8, 2014 22:35
-
-
Save dtolb/b2437a2ad007f2fe0f94 to your computer and use it in GitHub Desktop.
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
!/bin/bash | |
# | |
# Downloads the appropriate Chrome driver for this system. | |
# | |
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
BIN_DIR="${BASEDIR}/../bin" | |
ARCH=`uname -m` | |
PLATFORM=`uname -s` | |
DRIVER_NAME="chromedriver_{{arch}}.zip" | |
DRIVER_URL="http://chromedriver.storage.googleapis.com" | |
DRIVER_VERSION=`curl -sS ${DRIVER_URL}/LATEST_RELEASE` | |
if [ -x "${BIN_DIR}/chromedriver" ]; then | |
echo "Chrome driver already present." | |
exit 0 | |
fi | |
if [ "$?" != 0 -o -z "${DRIVER_VERSION}" ]; then | |
echo "Failed to determine the latest version of the Chrome driver." | |
exit 1 | |
fi | |
if [ "${PLATFORM}" == "Darwin" ]; then | |
ARCH="mac32" | |
elif [ "${ARCH}" == "i686" ]; then | |
ARCH="linux32" | |
else | |
ARCH="linux64" | |
fi | |
TEMP_DIR=`mktemp -d -t tmp.XXXXXX` | |
trap "rm -rf ${TEMP_DIR}" EXIT | |
ARCHIVE="${TEMP_DIR}/chrome-driver.zip" | |
DRIVER_NAME=`echo ${DRIVER_NAME} | sed "s/{{arch}}/${ARCH}/"` | |
echo "Downloading '${DRIVER_NAME}' version '${DRIVER_VERSION}'" | |
curl -sS "${DRIVER_URL}/${DRIVER_VERSION}/${DRIVER_NAME}" > "${ARCHIVE}" | |
echo "Unpacking Chrome driver" | |
mkdir -p "${BIN_DIR}" | |
pushd "${BIN_DIR}" > /dev/null | |
unzip "${ARCHIVE}" | |
popd > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment