Last active
March 29, 2023 17:39
-
-
Save naytseyd/b2b22d3254d5afb86446219548d77ce2 to your computer and use it in GitHub Desktop.
ChromeDriver installer for linux & mac systems
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 | |
error() { | |
echo -e "\033[1;31m$1\033[0m" | |
} | |
info() { | |
echo -e "\033[1;32m$1\033[0m" | |
} | |
case "$(uname -s)" in | |
Linux*) OS=linux;; | |
Darwin*) OS=mac;; | |
*) error "This OS is not supported"; exit 1;; | |
esac | |
CHROMEDRIVER_VERSION=$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE) | |
if command -v chromedriver >/dev/null 2>&1; then | |
current_version=$(chromedriver --version | awk '{print $2}') | |
if [[ "$current_version" == "$CHROMEDRIVER_VERSION" ]]; then | |
info "chromedriver version $CHROMEDRIVER_VERSION is already installed" | |
exit 0 | |
else | |
info "A different version of chromedriver is currently installed." | |
read -p "Would you like to update from version $current_version to $CHROMEDRIVER_VERSION? (y/n) " choice | |
case "$choice" in | |
y|Y ) info "Removing current version of chromedriver" | |
sudo rm -f "$(which chromedriver)" | |
;; | |
* ) info "Aborting installation" | |
exit 1 | |
;; | |
esac | |
fi | |
fi | |
clear | |
info "Latest ChromeDriver downloading & installing…" | |
wget -q "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_${OS}64.zip" -O /tmp/chromedriver.zip | |
if [ $? -ne 0 ]; then | |
error "Can't download ChromeDriver!" | |
exit 1 | |
fi | |
info "File extracting…" | |
unzip -q /tmp/chromedriver.zip -d /tmp/ | |
if [ $? -ne 0 ]; then | |
error "File can't extract!" | |
exit 1 | |
fi | |
info "File moving…" | |
sudo mv /tmp/chromedriver /usr/local/bin/chromedriver | |
if [ $? -ne 0 ]; then | |
error "File can't move!" | |
exit 1 | |
fi | |
info "Setting file permissions…" | |
sudo chmod +x /usr/local/bin/chromedriver | |
if [ $? -ne 0 ]; then | |
error "Can't set file permissions!" | |
exit 1 | |
fi | |
info "Installation completed!" | |
info "ChromeDriver version: $CHROMEDRIVER_VERSION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment