Linux下自动更新chromium

为了提高下载速度,下载压缩包时没有用wget,用的是axel,可以分段下载的下载利器,速度是wget的N倍。
可以直接apt-get install axel
或者去http://axel.alioth.debian.org/下载
或者把脚本里的axel去掉,换回wget…

#!/bin/bash
CHROME_DIR="/home/yins"
CHROME_TEMP="/home/yins/.chromium_update"

clean(){
	echo "update error!"
	rm LATEST
	rm chrome-linux.zip*
	exit
}

trap clean TERM
trap clean INT

cd "${CHROME_TEMP}"
if [ -a LATEST ];then
	old=`cat LATEST`
	rm LATEST
	echo "remove the latest file LATEST..."
else
	old=0
fi
if [ -a chrome-linux.zip ];then
	rm chrome-linux.zip
	echo "remove the latest file chrome-linux.zip..."
fi
if [ -a SUCCESS ];then
	rm SUCCESS
fi
echo "getting the LATEST..."
wget http://build.chromium.org/buildbot/snapshots/chromium-rel-linux-64/LATEST -O LATEST
last=`cat LATEST`
if [ ${last} -gt ${old} ] || [ ${last} -eq ${old} ] && [ ! -a SUCCESS ];then
	url="http://build.chromium.org/buildbot/snapshots/chromium-rel-linux-64/${last}/chrome-linux.zip"
	zenity --question --timeout 30 --title='new update' --text="latest : ${last}!! current: ${old} ,30 seconds to choose..."
	if [ $? -eq 0 ];then
		axel -a -n 10 "${url}"
		zenity --question --timeout 30 --title='file downloaded' --text="unzip now ? 30 seconds to choose..."
		if [ $? -eq 0 ];then
			unzip -o chrome-linux.zip -d "${CHROME_DIR}"
			touch SUCCESS
		fi
	else
		rm LATEST
	fi
else
	echo "no update,current: ${old} ..."
fi
echo "========OK========="

再配上计划任务:
先是

$crontab –e

第一次运行crontab的话需要先选择默认编辑器

内容:

#m h dom mon dow command
*/15 * * * * xxx
#每15分钟执行一次xxx命令