Add Gecko webdriver to linux images

This commit is contained in:
Sergey Dolin
2020-02-07 13:07:41 +05:00
parent 5b6b11c554
commit 8fd8a8d31d

View File

@@ -23,3 +23,26 @@ echo "Lastly, documenting what we added to the metadata file"
# ($HOME is /home/packer which is owned by packer.)
HOME=/root
DocumentInstalledItem "Firefox ($(firefox --version))"
# Download and unpack latest release of geckodriver
URL=https:`curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest|grep 'browser_download_url.*linux64.tar.gz'|sed -e 's/^.*"https://'|sed -e 's/"//g'`
echo "Downloading geckodriver $URL..."
wget "$URL" -O geckodriver.tar.gz
tar -xzf geckodriver.tar.gz
rm geckodriver.tar.gz
GECKODRIVER_BIN="/usr/bin/geckodriver"
mv "geckodriver" $GECKODRIVER_BIN
chown root:root $GECKODRIVER_BIN
chmod +x $GECKODRIVER_BIN
echo "GECKOWEBDRIVER=$GECKODRIVER_BIN" | tee -a /etc/environment
# Run tests to determine that the geckodriver installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if ! command -v geckodriver; then
echo "geckodriver was not installed"
exit 1
fi
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Geckodriver ($(geckodriver --version)); Gecko Driver is available via GECKOWEBDRIVER environment variable"