diff --git a/images/linux/scripts/installers/firefox.sh b/images/linux/scripts/installers/firefox.sh index e14df0c4..aa920774 100644 --- a/images/linux/scripts/installers/firefox.sh +++ b/images/linux/scripts/installers/firefox.sh @@ -23,3 +23,31 @@ 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=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest|grep 'browser_download_url.*linux64.tar.gz'|sed -E 's/^.*(https:.+)".*/\1/g') +echo "Downloading geckodriver $URL..." +wget "$URL" -O geckodriver.tar.gz +tar -xzf geckodriver.tar.gz +rm geckodriver.tar.gz + +GECKODRIVER_DIR="/usr/local/share/gecko_driver" +GECKODRIVER_BIN="$GECKODRIVER_DIR/geckodriver" + +mkdir -p $GECKODRIVER_DIR +mv "geckodriver" $GECKODRIVER_BIN + +chmod +x $GECKODRIVER_BIN +ln -s "$GECKODRIVER_BIN" /usr/bin/ +echo "GECKOWEBDRIVER=$GECKODRIVER_DIR" | 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" +ver=`./geckodriver --version|head -1|awk '{print $2}'` +DocumentInstalledItem "Geckodriver (${ver}); Gecko Driver is available via GECKOWEBDRIVER environment variable" diff --git a/images/linux/scripts/installers/google-chrome.sh b/images/linux/scripts/installers/google-chrome.sh index 5d19a0f4..979e2b37 100644 --- a/images/linux/scripts/installers/google-chrome.sh +++ b/images/linux/scripts/installers/google-chrome.sh @@ -1,7 +1,7 @@ #!/bin/bash ################################################################################ ## File: google-chrome.sh -## Desc: Installs google-chrome, chromedriver and selenium server +## Desc: Installs google-chrome and chromedriver ################################################################################ # Source the helpers for use with the script @@ -57,26 +57,3 @@ fi echo "Lastly, documenting what we added to the metadata file" DocumentInstalledItem "Chromedriver ($(chromedriver --version)); Chrome Driver is available via CHROMEWEBDRIVER environment variable" - -# Determine latest selenium standalone server version -SELENIUM_LATEST_VERSION_URL=https://api.github.com/repos/SeleniumHQ/selenium/releases/latest -SELENIUM_VERSION=$(curl $SELENIUM_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d ' ' -f 2) -SELENIUM_VERSION_MAJOR_MINOR=$(echo $SELENIUM_VERSION | cut -d '.' -f 1,2) - -# Download selenium standalone server -echo "Downloading selenium-server-standalone v$SELENIUM_VERSION..." -SELENIUM_JAR_NAME="selenium-server-standalone-$SELENIUM_VERSION.jar" -wget https://selenium-release.storage.googleapis.com/$SELENIUM_VERSION_MAJOR_MINOR/$SELENIUM_JAR_NAME - -echo "Testing to make sure that script performed as expected, and basic scenarios work" -if [ ! -f "$SELENIUM_JAR_NAME" ]; then - echo "Selenium server was not installed" - exit 1 -fi - -SELENIUM_JAR_PATH="/usr/share/java/selenium-server-standalone.jar" -mv $SELENIUM_JAR_NAME $SELENIUM_JAR_PATH -echo "SELENIUM_JAR_PATH=$SELENIUM_JAR_PATH" | tee -a /etc/environment - -echo "Lastly, documenting what we added to the metadata file" -DocumentInstalledItem "Selenium server standalone (available via SELENIUM_JAR_PATH environment variable)" diff --git a/images/linux/scripts/installers/selenium.sh b/images/linux/scripts/installers/selenium.sh new file mode 100644 index 00000000..3cb7c315 --- /dev/null +++ b/images/linux/scripts/installers/selenium.sh @@ -0,0 +1,31 @@ +#!/bin/bash +################################################################################ +## File: selenium.sh +## Desc: Installs selenium server +################################################################################ + +# Source the helpers for use with the script +source $HELPER_SCRIPTS/document.sh + +# Determine latest selenium standalone server version +SELENIUM_LATEST_VERSION_URL=https://api.github.com/repos/SeleniumHQ/selenium/releases/latest +SELENIUM_VERSION=$(curl $SELENIUM_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d ' ' -f 2) +SELENIUM_VERSION_MAJOR_MINOR=$(echo $SELENIUM_VERSION | cut -d '.' -f 1,2) + +# Download selenium standalone server +echo "Downloading selenium-server-standalone v$SELENIUM_VERSION..." +SELENIUM_JAR_NAME="selenium-server-standalone-$SELENIUM_VERSION.jar" +wget https://selenium-release.storage.googleapis.com/$SELENIUM_VERSION_MAJOR_MINOR/$SELENIUM_JAR_NAME + +echo "Testing to make sure that script performed as expected, and basic scenarios work" +if [ ! -f "$SELENIUM_JAR_NAME" ]; then + echo "Selenium server was not installed" + exit 1 +fi + +SELENIUM_JAR_PATH="/usr/share/java/selenium-server-standalone.jar" +mv $SELENIUM_JAR_NAME $SELENIUM_JAR_PATH +echo "SELENIUM_JAR_PATH=$SELENIUM_JAR_PATH" | tee -a /etc/environment + +echo "Lastly, documenting what we added to the metadata file" +DocumentInstalledItem "Selenium server standalone (available via SELENIUM_JAR_PATH environment variable)" \ No newline at end of file diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 6cef1b7f..f3b95f06 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -159,6 +159,7 @@ "{{template_dir}}/scripts/installers/ruby.sh", "{{template_dir}}/scripts/installers/rust.sh", "{{template_dir}}/scripts/installers/sbt.sh", + "{{template_dir}}/scripts/installers/selenium.sh", "{{template_dir}}/scripts/installers/sphinx.sh", "{{template_dir}}/scripts/installers/subversion.sh", "{{template_dir}}/scripts/installers/terraform.sh", diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index fde3d240..5938c2aa 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -162,6 +162,7 @@ "{{template_dir}}/scripts/installers/ruby.sh", "{{template_dir}}/scripts/installers/rust.sh", "{{template_dir}}/scripts/installers/sbt.sh", + "{{template_dir}}/scripts/installers/selenium.sh", "{{template_dir}}/scripts/installers/sphinx.sh", "{{template_dir}}/scripts/installers/subversion.sh", "{{template_dir}}/scripts/installers/terraform.sh",