Skip to content

Instantly share code, notes, and snippets.

@slhck
Created June 5, 2024 18:13
Show Gist options
  • Save slhck/2e12f8f132ea54de423b36a272857876 to your computer and use it in GitHub Desktop.
Save slhck/2e12f8f132ea54de423b36a272857876 to your computer and use it in GitHub Desktop.
Download latest chrome installer for Linux and rename
#!/usr/bin/env bash
#
# Download latest chrome installer for Linux and rename
set -e
cd "$(dirname "$0")" || exit 1
if ! command -v dpkg-deb &> /dev/null; then
echo "ERROR: dpkg-deb is not installed"
echo "Please install dpkg-deb and try again"
exit 1
fi
rm -f google-chrome-stable_current_amd64.deb
# download latest chrome installer
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# check the version from inside the file
chromeVersion=$(dpkg-deb -I google-chrome-stable_current_amd64.deb | grep Version | cut -d ' ' -f 3)
if [ -z "$chromeVersion" ]; then
echo "ERROR: Could not determine the version of the downloaded file"
exit 1
fi
# rename
mv -- google-chrome-stable_current_amd64.deb "google-chrome-stable_${chromeVersion}_amd64.deb"
echo "Downloaded and renamed to google-chrome-stable_${chromeVersion}_amd64.deb"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment