#!/bin/bash
set -e

# https://googlechromelabs.github.io/chrome-for-testing/ doesn't provide
# linux/arm64 binaries for chrome or chromedriver yet. Therefore on arm64, we
# install chromium instead of chrome.
if [ "$(dpkg --print-architecture)" = "arm64" ]; then
  apt update && apt install -y chromium-driver
else
  wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - &&\
    echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list &&\
    apt update &&\
    apt install -y google-chrome-stable
fi
