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:

https://www.chromium.org/administrators/frequently-asked-questions

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

Hi, relatively new to Linux but can’t get the .desktop script to work. My script is saved in my documents folder so I edited the .desktop script to

Exec=/home/user/Documents/update-chrome.sh

The .desktop opens the terminal but closes instantly, any help would be much appreciated. TIA.

is this script executable?

I believe so yes, both the .update and the .sh

to make sure that’s executable.
chmod +x FILENAME

also I suppose you correctly put the desktop file in
~/.local/share/applications ?

Yeah both should be executable, I used chmod 777 on both files however when I ran that and when I ran the +X command the terminal didn’t return anything, maybe I have gone wrong somewhere.

The desktop file is in usr/share/applications

Thanks for the assistance!

have you tried to run this script manually? would that work?


Also make sure this is modified to point to the correct file.

Exec=/home/repair/Downloads/update-chrome.sh

If I copy the .sh script into terminal it looks to work properly

The exec path is modified and looks correct, I replaced “repair” with my username

Can you show me the exact content of the desktop file?

Terminal = True should work and leave the terminal open.

The update script is unaltered and saved in “/home/steven/Documents/” with the filename “update-chrome.sh” and permissions have been granted -x. The terminal just opens and shuts immediately. I was wondering if it has anything to do with the fact I have enabled auto-login so my system doesn’t require a password?

I’ve no idea now…

You can add a few
echo FOO >> /home/USER/bar.log
in the upgrade script.

It can help you to see whether the script is executed correctly.

No problem! Thanks for the help, if I ever find the solution I’ll let you know what I did :slightly_smiling_face:

2 Likes