Skip to content

Commit

Permalink
install: Improve check for geckodriver.
Browse files Browse the repository at this point in the history
  • Loading branch information
nooblag committed Jan 18, 2022
1 parent ed83336 commit 1146795
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions pddgnimi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
bashinstall = """
# stop on any non-zero exit status
set -o errexit
# test if pip is available
if [ ! -x "$(command -v pip)" ]; then
# attempt to install it
Expand All @@ -55,25 +56,30 @@
exit 1
fi
fi
# ensure python dependencies are installed
pip install elemental html5lib htmlmin bs4
# ensure geckodriver for firefox is installed (https://github.com/mozilla/geckodriver/releases/latest)
# get the file and put it in a temp directory
tmpPath="$(mktemp --directory)"
# download version 0.30.0 into the tmpPath
geckoVersion='0.30.0'
geckodriverFile="geckodriver-v${geckoVersion}-linux64.tar.gz" # assumes x86_64 systems, will need fixing for arm and other possible deployments
wget --quiet --directory-prefix="${tmpPath}" "https://github.com/mozilla/geckodriver/releases/download/v${geckoVersion}/${geckodriverFile}"
if [ -s "${tmpPath}/${geckodriverFile}" ]; then
# extract the driver to somewhere like /usr/bin or something; use first entry in $PATH
firstPath="${PATH%%:*}"
echo "Extracting geckodriver to $firstPath"
sudo tar -xf "${tmpPath}/${geckodriverFile}" --directory "$firstPath"
else
printf "Failed to install geckodriver." >&2
exit 1
# test if geckodriver is available
if [ ! -x "$(command -v geckodriver)" ]; then
# attempt to install it
# get the file (https://github.com/mozilla/geckodriver/releases/latest) and put it in a temp directory
tmpPath="$(mktemp --directory)"
# download version 0.30.0 into the tmpPath
geckoVersion='0.30.0' # should probably work out a dynamic way to get github release assets rather than 'hardocding'
geckodriverFile="geckodriver-v${geckoVersion}-linux64.tar.gz" # assumes x86_64 systems, will need fixing for arm and other possible deployments
wget --quiet --directory-prefix="${tmpPath}" "https://github.com/mozilla/geckodriver/releases/download/v${geckoVersion}/${geckodriverFile}"
if [ -s "${tmpPath}/${geckodriverFile}" ]; then
# extract the driver to somewhere like /usr/bin or something---use first entry in $PATH
firstPath="${PATH%%:*}"
echo "Extracting geckodriver to $firstPath"
sudo tar -xf "${tmpPath}/${geckodriverFile}" --directory "$firstPath"
else
printf "Failed to install geckodriver." >&2
exit 1
fi
fi
# doing above with pip might be helpful instead! https://pypi.org/project/webdriver-manager/ ### ! ###
# handling geckodriver with pip/webdriver_manager might be better in future (https://pypi.org/project/webdriver-manager) ### ! ###
printf "Software check complete.\n\n"
"""
# run the above bash installer
Expand Down

0 comments on commit 1146795

Please sign in to comment.