Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1176240
  • 博文数量: 341
  • 博客积分: 12744
  • 博客等级: 上将
  • 技术积分: 4040
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-12 09:34
文章分类
文章存档

2014年(1)

2013年(10)

2012年(17)

2011年(63)

2010年(102)

2009年(107)

2008年(41)

分类: LINUX

2010-04-10 11:52:58

#!/bin/bash

trap "echo;echo 操作被手动终止;CLEANUP;exit 1" SIGINT SIGTERM

URL=http://build.chromium.org/buildbot/snapshots/chromium-rel-linux-64/
LOG=LATEST
FILE=chrome-linux.zip
TMP=/tmp
OPT=/opt

CLEANUP()
{
    rm $TMP/$LOG* 1>/dev/null 2>&1
    rm $TMP/$FILE* 1>/dev/null 2>&1
}

CLEANUP
wget $URL$LOG --directory-prefix=$TMP -q
if [ $? != 0 ]
then
    echo "Download version file failed"
    CLEANUP
    exit 1
fi
echo "Download version file successful"
if [ ! -f $OPT/chrome-linux/$LOG ]
then
    echo "can not find old version file"
elif [ `diff $OPT/chrome-linux/$LOG $TMP/$LOG|wc -l` -eq 0 ]
then
    echo "Chromium update to date"
    CLEANUP
    exit 0
fi

echo -n "Current version "
cat $OPT/chrome-linux/$LOG
echo
echo -n "Update to version "
cat $TMP/$LOG
echo

VERSION=`cat $TMP/$LOG`
#wget $URL$VERSION/$FILE --directory-prefix=$TMP

axel -n 10 -o $TMP $URL$VERSION/$FILE
if [ $? != 0 ]
then
    echo "Download update file failed"
    CLEANUP
    exit 1
fi
echo "Download update file successful"

unzip -o -q $TMP/$FILE -d $OPT
if [ $? != 0 ]
then
    echo "Extract update file failed"
    CLEANUP
    exit 1
fi
echo "Extract update file successful"

cp $TMP/$LOG $OPT/chrome-linux/ -f
echo "All update done"
CLEANUP
exit 0


阅读(1299) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~