Created
September 16, 2012 19:39
-
-
Save jyc/3734053 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Installation directory - change this to a directory of your choice | |
| # Please make sure the directory exists first, or the script won't work | |
| INSTALLDIR=$HOME | |
| # Development channel to use. 'dev', 'beta' or 'stable'. 'stable' does | |
| # not appear to work. | |
| USECHANNEL="beta" | |
| CHECKINTERVAL=300 | |
| # Determine the architecture of the machine in use and set variables accordingly | |
| if [ -z "$ARCH" ]; then | |
| case "$( uname -m )" in | |
| i686) ARCH=i686 ;; | |
| *) ARCH=$( uname -m ) ;; | |
| esac | |
| fi | |
| if [ "$ARCH" = "i686" ]; then | |
| DIRSUFFIX="" | |
| elif [ "$ARCH" = "x86_64" ]; then | |
| DIRSUFFIX="_x64" | |
| else | |
| echo "The ARCH should be either i686 or x86_64. Exiting." | |
| exit | |
| fi | |
| if [ ! -f CHROMIUM_CURRENTBUILD ]; then | |
| echo "0" > CHROMIUM_CURRENTBUILD | |
| fi | |
| CURRENTBUILD=$(cat CHROMIUM_CURRENTBUILD) | |
| echo $CURRENTBUILD | |
| while : | |
| do | |
| # Determine the build number of the latest build | |
| #LATESTBUILD=$(curl http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux/LAST_CHANGE) | |
| curl http://omahaproxy.appspot.com/all?csv=1 > /tmp/chrome-omaha.csv | |
| while IFS=, read os chan curr_ver prev_ver curr_rdate prev_rdate base_trunk_rev branch_rev base_wk_rev true_branch wk_ver v8_ver | |
| do | |
| if [[ "$os" == "linux" && "$chan" == "$USECHANNEL" ]]; then | |
| LATESTBUILD=$base_trunk_rev | |
| fi | |
| done < /tmp/chrome-omaha.csv | |
| if [[ $CURRENTBUILD -ge $LATESTBUILD ]]; then | |
| sleep $CHECKINTERVAL | |
| continue # no need to update | |
| fi | |
| # notify-send -i appointment -u normal "Chromium can be updated" "Close Chromium and wait for a successful notification." | |
| # PID=`/sbin/pidof chrome` | |
| # echo $PID | |
| # while kill -0 $PID; do | |
| # sleep 1 | |
| # done | |
| # The URL to download from | |
| CHROMEURL="http://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux"$DIRSUFFIX/$LATESTBUILD/"chrome-linux.zip" | |
| cd $INSTALLDIR | |
| if [ -e chrome-linux.zip ]; then # Check to see if `chrome-linux.zip` already exists | |
| mv chrome-linux.zip chrome-linux.zip.old # if it does, rename it to chrome-linux.zip.old as backup | |
| fi # in case the current build has problems | |
| wget -O chrome-linux.zip $CHROMEURL | |
| unzip -u -o ./chrome-linux.zip | |
| echo $LATESTBUILD > CHROMIUM_CURRENTBUILD | |
| CURRENTBUILD=$LATESTBUILD | |
| # notify-send -i appointment -u normal "Chromium was updated successfully" "You may safely restart Chromium." | |
| notify-send -i appointment -u normal "Chromium updated successfully" "Chromium was updated from $CURRENTBUILD to $LATESTBUILD." | |
| sleep $CHECKINTERVAL | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment