forked from ritvikkhanna09/AutoLoginBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updatechromedriver.sh
executable file
·52 lines (44 loc) · 2 KB
/
updatechromedriver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
######################################################
# PURPOSE : Update Chrome Driver to Chrome browser ##
# version. ##
# ##
# ##
# ##
######################################################
declare -rx mkdir="/bin/mkdir"
declare -rx rm="/bin/rm"
declare -rx cut="/usr/bin/cut"
declare -rx which="/usr/bin/which"
CURL=$($which curl)
GOOGLECHROME=$(which google-chrome)
UNZIP=$($which unzip)
CHROMEDRIVERDIRECTORY=/opt/google/chrome
CHROMEDRIVERPATH=/opt/google/chrome/chromedriver
CHROMEDRIVERURL='https://chromedriver.storage.googleapis.com'
# Test Default chromedriver path /opt/google/chrome/
# if test ! -f "$CHROMEDRIVERPATH"
# then
# $mkdir -p $CHROMEDRIVERDIRECTORY
# $CURL -o chromedriverlatest.zip $CHROMEDRIVERURL
# $UNZIP chromedriverlatest.zip -d $CHROMEDRIVERDIRECTORY
# $rm -f chromedriverlatest.zip
# fi
# Get Chrome browser version
CHROMEVERSION=$($GOOGLECHROME --version | $cut -d ' ' -f 3 | $cut -d '.' -f 1)
printf "Google chrome version : %s\n" "$CHROMEVERSION";
# Get Chrome driver version
CHROMEDRIVERVERSION=$($CHROMEDRIVERPATH --version | $cut -d ' ' -f 2 | $cut -d '.' -f 1)
printf "Chrome driver version : %s\n" "$CHROMEDRIVERVERSION"
# Compare Chrome driver version & Chrome browser version
if test "$CHROMEVERSION" != "$CHROMEDRIVERVERSION"
then
printf "\x1b[1;31m The versions are different. \x1b[0m\n"
printf "\x1b[1;33m Downloading...\x1b[0m"
chromedriverlatest=$($CURL -s "$CHROMEDRIVERURL/LATEST_RELEASE")
printf "\x1b[1;33m the lastest version of chrome driver: %s\x1b[0m\n" "$chromedriverlatest"
$CURL -s -o chromedriverlatest.zip "$CHROMEDRIVERURL/$chromedriverlatest/chromedriver_linux64.zip"
$UNZIP -o chromedriverlatest.zip -d $CHROMEDRIVERDIRECTORY
$rm -f chromedriverlatest.zip
fi
printf "\x1b[1;92mVersions are equal. It's OK !\n \x1b[0m\n"