Skip to content

Instantly share code, notes, and snippets.

@anthonybaldwin
Created November 12, 2019 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonybaldwin/d0afa9da4cdf974364b7ee2e51df9960 to your computer and use it in GitHub Desktop.
Save anthonybaldwin/d0afa9da4cdf974364b7ee2e51df9960 to your computer and use it in GitHub Desktop.
Download most recent Chromedriver and update version file
#!/usr/bin/env bash
# Version
CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
# Remove existing
rm chromedriver
rm chromedriver-mac
rm chromedriver.exe
# Need unzip and wget
if test ! $(which unzip) || test ! $(which wget); then
# Should only need to install unzip, but checking both just in case
if [[ "$(uname)" == "Linux" ]]; then
# Update package list just in case
sudo apt-get update
# wget
if test ! $(which wget); then
echo "Installing wget..."
sudo apt-get install -y wget
fi
# unzip
if test ! $(which unzip); then
echo "Installing unzip..."
sudo apt-get install -y unzip
fi
fi
# OS X needs homebrew to install wget and unzip
if [[ "$(uname)" == "Darwin" ]]; then
# Homebrew
if test ! $(which brew); then
echo "Installing Homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# wget
if test ! $(which wget); then
echo "Installing wget..."
brew install wget
fi
# unzip
if test ! $(which unzip); then
echo "Installing unzip..."
brew install unzip
fi
fi
fi
# OS X
echo "Downloading and extracting chromedriver-mac..."
wget -Nq http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_mac64.zip
unzip chromedriver_mac64.zip
rm chromedriver_mac64.zip
echo "moving chromedriver to chromedriver-mac..."
mv -f chromedriver chromedriver-mac
# Linux
echo ""
echo "Downloading and extracting chromedriver..."
wget -Nq http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
rm chromedriver_linux64.zip
# Windows
echo ""
echo "Downloading and extracting chromedriver.exe..."
wget -Nq http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_win32.zip
unzip chromedriver_win32.zip
rm chromedriver_win32.zip
# Display md5sums
echo ""
echo "md5sums are..."
md5sum chromedriver*
# Update driver-versions.txt
echo ""
echo "Updating driver-versions.txt..."
sed -i.bak '/chromedriver/d' driver-versions.txt && rm driver-versions.txt.bak
md5sum chromedriver* | awk -v v="$CHROMEDRIVER_VERSION" '{ printf "%-20s %-20s %-20s\n", $2, v, $1 }' >> driver-versions.txt
# Spit out version number
echo ""
echo "Sucesfully downloaded drivers for Chrome $CHROMEDRIVER_VERSION and updated driver-versions.txt."
echo "Please commit any changes and make a pull request."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment