Skip to content

Instantly share code, notes, and snippets.

@GGontijo
Created November 7, 2024 13:06
Show Gist options
  • Save GGontijo/de34e888ed1dbc449f90addb73d79057 to your computer and use it in GitHub Desktop.
Save GGontijo/de34e888ed1dbc449f90addb73d79057 to your computer and use it in GitHub Desktop.
Atualizar o google-chrome instalado localmente
#!/bin/bash
# Atualizar o cache de pacotes
sudo apt update -y
# Verificar se o Chrome está instalado
if ! command -v google-chrome &> /dev/null; then
echo "Google Chrome não encontrado. Instalando..."
wget -q -O google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome.deb
sudo apt install -f -y
rm google-chrome.deb
echo "Google Chrome instalado com sucesso."
exit 0
fi
# Obter a última versão do Chrome disponível no repositório oficial
LATEST_VERSION=$(wget -qO- https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages | grep -m2 'google-chrome-stable' | grep -oP '\d+\.\d+\.\d+')
# Obter a versão do Chrome instalada
INSTALLED_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+')
echo "Versão instalada do Chrome: $INSTALLED_VERSION"
echo "Última versão do Chrome: $LATEST_VERSION"
# Comparar versões e atualizar se necessário
if [ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]; then
echo "Nova versão disponível. Atualizando Chrome..."
wget -q -O google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome.deb
sudo apt install -f -y
rm google-chrome.deb
echo "Google Chrome atualizado para a versão $LATEST_VERSION."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment