Skip to content

Instantly share code, notes, and snippets.

@mbruno-kr
Created September 24, 2021 21:23
Show Gist options
  • Save mbruno-kr/3b91c1ee4886c198e770023392d78c64 to your computer and use it in GitHub Desktop.
Save mbruno-kr/3b91c1ee4886c198e770023392d78c64 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
apt-get update
download () {
curl --silent --show-error --location --fail --retry 3 \
--output "$1" "$2"
}
## Remove Existing
if command -v google-chrome > /dev/null 2>&1; then
echo "$(google-chrome --version) is currently installed; replacing it"
apt-get -y --purge remove google-chrome-stable > /dev/null 2>&1 || true
rm -f "$(command -v google-chrome)" > /dev/null 2>&1 || true
else
echo "Google Chrome is not currently installed; installing it"
fi
CHROME_URL="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
echo "Setting chrome version to ${CHROME_VERSION}"
if [ -z "${CHROME_VERSION}" ]; then
export CHROME_VERSION="latest"
echo "Chrome version not found as first argument! Setting chrome version to latest"
fi
# Download
if [ "${CHROME_VERSION}" != "latest" ]; then
CHROME_URL="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}-1_amd64.deb"
fi
echo "Downloading: $CHROME_URL"
# Install
APP_INDICATOR_DEB="libappindicator.deb"
CHROME_DEB="google-chrome.deb"
echo "Installing libappindicator3-7..."
download "$APP_INDICATOR_DEB" "http://ftp.us.debian.org/debian/pool/main/libi/libindicator/libindicator3-7_0.5.0-3+b1_amd64.deb"
apt-get install -f "./$APP_INDICATOR_DEB"
rm -rf "./$APP_INDICATOR_DEB"
echo "Installing libappindicator3-1..."
download "$APP_INDICATOR_DEB" "http://ftp.us.debian.org/debian/pool/main/liba/libappindicator/libappindicator3-1_0.4.92-4_amd64.deb"
apt-get install -f "./$APP_INDICATOR_DEB"
rm -rf "./$APP_INDICATOR_DEB"
echo "Installing chrome version: ${CHROME_VERSION}"
download "$CHROME_DEB" "$CHROME_URL"
apt-get update
apt-get install -f "./$CHROME_DEB"
rm -rf "./$CHROME_DEB"
# test/verify installation
if [ "$CHROME_VERSION" != "latest" ]; then
if google-chrome --version | grep "$CHROME_VERSION" > /dev/null 2>&1; then
:
else
echo "Something went wrong; Google Chrome could not be installed"
exit 1
fi
else
if google-chrome --version > /dev/null 2>&1; then
:
else
echo "Something went wrong; Google Chrome could not be installed"
exit 1
fi
echo "$(google-chrome --version) has been installed to $(which google-chrome)"
echo "Chrome: $CHROME_VERSION" >> "${HOME}/.browser-versions"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment