De acordo com as Leis 12.965/2014 e 13.709/2018, que regulam o uso da Internet e o tratamento de dados pessoais no Brasil, ao me inscrever na newsletter do portal DICAS-L, autorizo o envio de notificações por e-mail ou outros meios e declaro estar ciente e concordar com seus Termos de Uso e Política de Privacidade.


Baixar ultima versão Chromium automaticamente

Colaboração: André Marques Saunite

Data de Publicação: 20 de julho de 2012

Eu uso Debian Testing, mas normalmente a versão Chrome que existe nos repositórios não é a mais atual, e eu achei que era muito tempo perdido ficar sempre compilando as versões mais novas, e foi então que eu encontrei esse site onde são gerados snapshots de cada versão do Chrome, para Linux i386, x86_64, Mac, Windows e até Arm:

http://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html

É só escolher a versão, baixar, descompactar, e pronto, um chromium totalmente livre e usável!

Mas por que ter todo o trabalho de baixar, descompactar, copiar os plugins que não vem por default (como o do flash), quando eu posso ter um script para fazer tudo isso?

Foi por isso que eu escrevi o script abaixo, o uso é bem simples:

Para baixar e instalar a versão mais recente do Chromium: getChrome install

Para somente baixar a versão mais nova: getChrome download

Para baixar uma versão especifica: getChrome download < versão desejada>

Para baixar e instalar uma versão especifica: getChrome install < versão desejada>

Para somente mostrar qual é versão mais atual: getChrome print

Caso você já tenha baixado o arquivo .zip, pode instalar com o script: getChrome install < arquivo .zip>

E para tudo isso funcionar perfeitamente, você só precisa configurar algumas variáveis no script antes de utilizar:

  WORKDIR="${HOME}/Downloads/" # O diretório para onde vão ser baixados os .zip
  CHROMIUMINSTALLDIR="/opt/" # Diretório onde o Chromium será instalado (a pasta chrome-linux vai ser criada nesse diretório
  ARCH=Linux_x64 # A arquitetura do Chromium, tem que ser exatamente igual ao da lista existente em http://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html 
  USEROWNER="andre" # Usuario que será dono do diretório do Chromium
  GROUPOWNER="andre" # Grupo que será dono do diretório do Chromium
  FLASHDIR="/opt/flashplayer/" # diretório onde está o plugin do flash (libflashplayer.so)

E aqui segue o script (Download direto do script)

  #!/bin/bash 
  
  WORKDIR="${HOME}/Downloads/"
  CHROMIUMINSTALLDIR="/opt/"
  ARCH=Linux_x64
  ALREADYEXISTS="false"
  USEROWNER="andre"
  GROUPOWNER="andre"
  FLASHDIR="/opt/flashplayer/"
  LASTVERSION="nolastversionyet";
  
  # Index at:
  # http://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html
  
  downloadSpecific () {
         if [ -d $WORKDIR ] ; then
                 cd $WORKDIR
                 if [ -z $1 ]; then 
                         echo "No input specified for 'downloadSpecific' function! Aborting!"; 
                         exit 9;
                 fi
  
                 LASTVERSION=$1
                 if [ ! -e chrome-linux_${LASTVERSION}.zip ] ; then 
                         wget http://commondatastorage.googleapis.com/chromium-browser-snapshots/${ARCH}/${LASTVERSION}/chrome-linux.zip -O ${WORKDIR}/chrome-linux.zip;
                         if [ ! -s chrome-linux.zip ]; then 
                                 echo "File has no contents! Apparently the file doesn't exist in the repository, please double check in ";
                                 echo "http://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?path=${ARCH}/ to be "
                                 echo "sure the release exist!!!";
                                 rm chrome-linux.zip;
                                 exit 8;
                         fi
                         mv chrome-linux.zip chrome-linux_${LASTVERSION}.zip
                         echo "Chromium version ${LASTVERSION} saved as chrome-linux_${LASTVERSION}.zip"
                         export DOWNLOADEDFILE="chrome-linux_${LASTVERSION}.zip";
                 else 
                         ALREADYEXISTS="true";
                 fi
         else 
                 echo "Directory \"$WORKDIR\" not found";
                 exit 10;
         fi
         if [ -n "${USEROWNER}" ] && [ -n "${GROUPOWNER}" ]; then
                 chown -R ${USEROWNER}:${GROUPOWNER} ${WORKDIR}
         fi
  }
  
  download () {
         if [ -d $WORKDIR ] ; then
                 cd $WORKDIR
                 wget -q http://commondatastorage.googleapis.com/chromium-browser-snapshots/${ARCH}/LAST_CHANGE -O ${WORKDIR}/LAST_CHANGE
                 LASTVERSION=`cat LAST_CHANGE`;
                 if [ ! -e chrome-linux_${LASTVERSION}.zip ] ; then 
                         wget http://commondatastorage.googleapis.com/chromium-browser-snapshots/${ARCH}/${LASTVERSION}/chrome-linux.zip -O ${WORKDIR}/chrome-linux.zip;
                         mv chrome-linux.zip chrome-linux_${LASTVERSION}.zip
                         echo "Chromium version ${LASTVERSION} saved as chrome-linux_${LASTVERSION}.zip"
                         rm LAST_CHANGE;
                         export DOWNLOADEDFILE="chrome-linux_${LASTVERSION}.zip";
                 else 
                         ALREADYEXISTS="true";
                         rm LAST_CHANGE;
                 fi
         else 
                 echo "Directory \"$WORKDIR\" not found";
                 exit 1;
         fi
         if [ -n "${USEROWNER}" ] && [ -n "${GROUPOWNER}" ]; then
                 chown -R ${USEROWNER}:${GROUPOWNER} ${WORKDIR}
         fi
  }
  
  unpackAndInstall () {
         #echo "unpack and install: $1";
         if [ ! -z $1 ];  then 
                 export FILETOINSTALL=$1;
         fi
  
         if [[ ! $FILETOINSTALL =~ ^\/ ]]; then
                 FILETOINSTALLBASENAME="`basename $FILETOINSTALL`";
                 FILETOINSTALL="${WORKDIR}/${FILETOINSTALLBASENAME}";
                 unset $FILETOINSTALLBASENAME;
         fi
  
         if [ -e ${CHROMIUMINSTALLDIR}/chrome-linux.old ] ; then
                 rm -rf ${CHROMIUMINSTALLDIR}/chrome-linux.old 
         fi
         if [ -e ${CHROMIUMINSTALLDIR}/chrome-linux ] ; then
                 mv ${CHROMIUMINSTALLDIR}/chrome-linux ${CHROMIUMINSTALLDIR}/chrome-linux.old 
         fi
         cd ${CHROMIUMINSTALLDIR};
         unzip ${FILETOINSTALL};
         chown -R root:users chrome-linux
         chmod -R g+r,o+r chrome-linux
         chmod g+x,o+x chrome-linux
         find chrome-linux -type d -exec chmod g+x,o+x {} \+
         find chrome-linux -writable -exec chmod g+w,o+w {} \+
         find chrome-linux -executable -exec chmod g+x,o+x {} \+
         cd chrome-linux
         mkdir plugins 2> /dev/null
         ln -s ${FLASHDIR}/libflashplayer.so ./plugins/libflashplayer.so
         ln -s /usr/lib/jvm/java-7-sun/jre/lib/amd64/libnpjp2.so ./plugins/libnpjp2.so
         cd - > /dev/null
  }
  
  # main()
  if [ $# -eq 0 ]; then
         echo "Usage: $0 < print|download|install> [chrome-linux.zip|release number]";
         exit 4;
  fi
  
  if  [ $1 != "download" ] && [ $1 != "print" ] && [ $1 != "install" ] && [ $1 != "--help" ] ; then
         echo "Usage: $0 < print|download|install> [chrome-linux.zip|release number]";
         exit 3;
  fi
  
  if [ $1 = "print" ] ; then
         wget -q http://commondatastorage.googleapis.com/chromium-browser-snapshots/${ARCH}/LAST_CHANGE -O LAST_CHANGE
         echo "Last version is `cat LAST_CHANGE`";
         rm LAST_CHANGE;
         exit 0;
  fi
  if [ $1 = "download" ]; then
         if [ ! -z $2 ] && [ ! -e $2 ] ; then 
                 if [[ $2 =~ ^[0-9]+$ ]]; then 
                         downloadSpecific $2;
                         if [ $ALREADYEXISTS == "true" ]; then
                                 echo "File chrome-linux_${LASTVERSION}.zip Exists, aborting";
                                 exit 7;
                         fi 
                         exit 0;
                 fi
         fi
         if [ -z $2 ]; then
                 download
                 if [ $ALREADYEXISTS == "true" ]; then
                         echo "File chrome-linux_${LASTVERSION}.zip Exists, aborting";
                         exit 2;
                 fi 
         else 
                 echo "$2 is not recognized!";
                 echo "Usage: $0 < print|download|install> [chrome-linux.zip|release number]";
         fi
  
  fi
  if [ $1 = "install" ]; then
         if [[ $EUID -ne 0 ]]; then
                 echo "The install option needs to be run as root!";
                 exit 5;
         fi
         if [ ! -z $2 ] && [ -e $2 ] ; then 
                 unpackAndInstall $2;
                 exit 0;
         elif [ ! -z $2 ] && [ ! -e $2 ] ; then
                 if [[ $2 =~ ^[0-9]+$ ]]; then 
                         downloadSpecific $2;
                         if [ $ALREADYEXISTS == "true" ]; then
                                 echo "File chrome-linux_${LASTVERSION}.zip Exists, aborting";
                                 exit 12;
                         fi 
                         unpackAndInstall ${WORKDIR}/${DOWNLOADEDFILE};
                         exit 0;
                 else 
                         echo "Error: File $2 not found";
                         exit 6;
                 fi
         fi 
         download;
         if [ $ALREADYEXISTS == "true" ]; then
                 echo "File chrome-linux_${LASTVERSION}.zip Exists, aborting";
                 exit 11;
         fi 
         cd $WORKDIR;
         unpackAndInstall ${WORKDIR}/${DOWNLOADEDFILE};
  fi
  
  if [ $1 = "--help" ]; then
         echo "Usage: $0 < print|download|install> [chrome-linux.zip|release number]";
  fi

Adicionar comentário

* Campos obrigatórios
5000
Powered by Commentics

Comentários

Nenhum comentário ainda. Seja o primeiro!


Veja a relação completa dos artigos de André Marques Saunite