26 May 2010

latest chromium

if you prefer a faster browser than firefox, then google chrome is what you probably want to be running.  if you want something a bit more bleeding edge than waiting for google to push out patches to their chrome release, chromium is what you want.

since they release updates several times a day, i wrote a small bash script to grab the latest version released and set it up as my default browser.  (of course, this is for linux.)  and this is specifically for the 64-bit linux platform.  swap out the CHROMIUM_URL values in the script for your appropriate architecture.

#!/bin/bash
##  get_latest_build.sh
##  this assumes you've set up sudo
##  if not, then change the sudos to "su -c"

CHROME_DIR=/usr/local/bin/chrome
SNAPSHOTS_URL=http://build.chromium.org/buildbot/snapshots
CHROMIUM_URL=$SNAPSHOTS_URL/chromium-rel-linux-64
#CHROMIUM_URL=$SNAPSHOTS_URL/chromium-rel-linux
PLUGINS_DIR=~/.mozilla/plugins

if [ ! -d $CHROME_DIR ]; then
  echo "creating $CHROME_DIR..."
  sudo mkdir $CHROME_DIR
fi

echo "get latest version number..."
wget -nv -O "/tmp/LATEST" "$CHROMIUM_URL/LATEST"
LATEST=`cat /tmp/LATEST`
echo "LATEST = $LATEST"

echo "download latest..."
wget -O "$CHROME_DIR/chrome-linux.zip" 
        "$CHROMIUM_URL/$LATEST/chrome-linux.zip"

echo "unzip latest..."
unzip "$CHROME_DIR/chrome-linux.zip" -d "$CHROME_DIR"

echo "rename the directory with build number..."
mv "$CHROME_DIR/chrome-linux" "$CHROME_DIR/chrome-linux-$LATEST"

echo "reset soft link..."
rm "$CHROME_DIR/chrome_linux"
ln -s "$CHROME_DIR/chrome-linux-$LATEST" "$CHROME_DIR/chrome_linux"

if [ -d $PLUGINS_DIR ]; then
  echo "copy plugins directory into new chrome dir..."
  cp -r $PLUGINS_DIR $CHROME_DIR/chrome_linux/
fi

echo "setting permissions on directory..."
chmod ug+rx "$CHROME_DIR/chrome_linux"

echo "done!"