#!/bin/sh
# by liksys © 2009 v 1.1
# update chromium snapshot
#
#
http://linsovet.com/chrome-chromium-script-to-get-shapshot ###########
BASE_DIR=/opt
## for some system install to /usr/local. uncomment this
#BASE_DIR=/usr/local
LIB_DIR=/lib
VER_FILE=$HOME/.chrome-last-snapshot-version
URL='http://build.chromium.org/buildbot/snapshots/chromium-rel-linux'
[ -d $LIB_DIR ] || mkdir -p $LIB_DIR
cd $BASE_DIR
[ -e /lib/libnss3.so -a ! -e $LIB_DIR/libnss3.so.1d ] && ln -s /lib/libnss3.so $LIB_DIR/libnss3.so.1d
[ -e /lib/libnssutil3.so -a ! -e $LIB_DIR/libnssutil3.so.1d ] && ln -s /lib/libnssutil3.so $LIB_DIR/libnssutil3.so.1d
[ -e /lib/libsmime3.so -a ! -e $LIB_DIR/libsmime3.so.1d ] && ln -s /lib/libsmime3.so $LIB_DIR/libsmime3.so.1d
[ -e /lib/libssl3.so -a ! -e $LIB_DIR/libssl3.so.1d ] && ln -s /lib/libssl3.so $LIB_DIR/libssl3.so.1d
[ -e /lib/libplds4.so -a ! -e $LIB_DIR/libplds4.so.0d ] && ln -s /lib/libplds4.so $LIB_DIR/libplds4.so.0d
[ -e /lib/libplc4.so -a ! -e $LIB_DIR/libplc4.so.0d ] && ln -s /lib/libplc4.so $LIB_DIR/libplc4.so.0d
[ -e /lib/libnspr4.so -a ! -e $LIB_DIR/libnspr4.so.0d ] && ln -s /lib/libnspr4.so $LIB_DIR/libnspr4.so.0d
[ -e $VER_FILE ] || echo 0 > $VER_FILE
LOC_VER=`cat $VER_FILE`
LAST_VER=`wget -qO- $URL/LATEST`
if [ $LOC_VER -eq $LAST_VER ]; then
echo "----- Local version is fresh! -----"
exit 0
fi
wget -P /tmp $URL/$LAST_VER/chrome-linux.zip
rm -rf chrome-linux
unzip /tmp/chrome-linux.zip
rm -f /tmp/chrome-linux.zip
find chrome-linux -type d -exec chmod 755 '{}' \;
find chrome-linux -type f -exec chmod 644 '{}' \;
chmod +x chrome-linux/chrome
echo $LAST_VER > $VER_FILE
[ -d $HOME/bin ] || mkdir -p $HOME/bin
[ -e $HOME/bin/chrome ] || ln -s $BASE_DIR/chrome-linux/chrome $HOME/bin/chrome
echo "----- Installation sucsessfully! -----"