Google Chrome Update Script

Hi All,

I just wanted to throw this out there, hoping to make a contribution to the community. It’s a Google Chrome update script, based in part on the Google Chrome Install Tutorial previously posted for Clear Linux. I know that in the tutorial it said to just rerun the install commands periodically or whenever you see a new update, but this script will poll the latest version from Google Chrome’s Omaha Proxy, compare it to the version of the installed executable, then offer to update the executable for you. I made the script interactive so that you can run it manually or from autostart, but it can easily be modified to remove all the interactive elements.

I cannot guarantee that changes in Omaha Proxy or a sudden escalation in magnitude of version numbers won’t necessitate a change in the script to acommodate. The script can probably use some more refinement.

#!/bin/bash

clear

divider="==============================\n"
latest=$(curl -s https://omahaproxy.appspot.com/linux)
current=$(/opt/google/chrome/google-chrome --version | cut -c15-)

printf "$divider  \033[1mGoogle Chrome Update Check\033[0m\n$divider"
printf "Latest Version:  $latest\n"
if [ $latest = $current ]
then
  printf "Current Version: $current\n$divider \033[1m\e[32mGoogle Chrome is up to date.\033[0m\n"
else
  printf "Current Version: \033[3m\e[31m$current\033[0m\n$divider  \033[1m\e[31mUPDATE GOOGLE CHROME NOW!!\033[0m\n$divider"
  read -n 1 -r -p "Do you want to update now? (y/n): " response
  case $response in
    [Yy]* )
      printf "\n\n\033[1mDownloading:\033[0m\n\n";
      curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm;
      printf "\n\033[1mUpdating:\033[0m\n\n";
      sudo rpm -U --nodeps google-chrome*.rpm;
      rm -f google-chrome*.rpm;
      printf "\n\033[1m\e[32mGoogle Chrome has been updated.\033[0m\n";;
    * )
      printf "\n\n\033[1m\e[31mPlease update soon!!!\033[0m\n";;
  esac
fi
printf "\n"

For those running Gnome, I have the following .desktop for both autostart and applications folders:

[Desktop Entry]
Type=Application
Name=update-chrome
Exec=/home/repair/Downloads/update-chrome.sh
StartupNotify=false
Terminal=true

Let me know what you think!

1 Like

Is there no way to use the official URL’s for this project? Using HTTP instead of HTTPS also makes it further insecure… What if the person who runs this stops updating this?

@ahkok, I’m glad you caught that. I just swapped in https and the script works just as well. Easy fix.

As for the official URL, I was under the impression that this was an official URL for the project status? It lists all of Chrome’s releases, by OS and channel. It’s also listed in the FAQ from Chromium:

NOTE: I edited the script in the original post to reflect the HTTPS change.

2 Likes

Sorry for editing things on the fly, but I just noticed from that Chromium FAQ how I could get just the version number from Omaha Proxy rather than grepping / cutting it out of the raw data. Now I just need to do the same thing from the “google-chrome --version” command… I still worry that a version number shift is going to cause numbers to be dropped off the end using cut. More research needed.

NVM, looks like this domain is indeed registered to Google, so it should be reasonably safe with HTTPS.

One more small update, just changing

cut -b 15-26

to

cut -c15-

in order to get the whole version string from the google-chrome executable every time. Now as long as Google Chrome doesn’t change names…

And thanks for the double-check, @ahkok!!

1 Like