2014-07-09-160003_
[12306_ticket_helper.git] / cronupd.sh
blobcdaf39dd1811068035958786ca2f67d02d71a31d
1 #!/bin/sh
2 #SHELL=/bin/sh
3 #PATH=/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin
4 #*/5 * * * * huxs /bin/sh /opt/galaxy/git/12306_ticket_helper_iccfish/cronupd.sh 2>&1 >/opt/galaxy/git/12306_ticket_helper_iccfish/uplog.user
6 export GIT_AUTHOR_NAME="Galaxy"
7 export GIT_AUTHOR_EMAIL=galaxy001@gmail.com
8 export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
9 export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
11 env
12 date
14 cd /opt/galaxy/git/12306_ticket_helper_iccfish/
15 mv 12306_ticket_helper.user.js 12306_ticket_helper.user.js.old
16 mv version.js version.js.old
17 mv 12306_ticket_helper.crx 12306_ticket_helper_last.crx
18 wget -S http://www.fishlee.net/service/update/44/version.js -o updatetime.log
19 wget -S http://www.fishlee.net/Service/Download.ashx/44/47/12306_ticket_helper.user.js -a updatetime.log
20 wget -S http://www.fishlee.net/Service/Download.ashx/44/63/12306_ticket_helper.crx -a updatetime.log
22 THEVER=`sha1sum 12306_ticket_helper.user.js`
23 # 4.5.0 @ 2013-01-26 18:15:56 CST
24 #echo $THEVER|awk '{print $1}' > now.ver.user
25 DATETIME=`date +%F-%H%M%S`
26 THEVER=${DATETIME}_${THEVER}
27 JUSTVER=`echo ${THEVER}|awk '{gsub(/\./,"");print $1}'`
29 cmp 12306_ticket_helper.user.js 12306_ticket_helper.user.js.old
30 if [ $? -ne 0 ]; then
31 unzip -oDDd chrome.new 12306_ticket_helper.crx
32 if [ $? -eq 1 ]; then
33 rm -fr chrome
34 mv chrome.new chrome
35 git add chrome
36 else
37 rm -fr chrome.new
39 mv 12306_ticket_helper.crx bak/12306_ticket_helper_${JUSTVER}.crx
40 git add bak/12306_ticket_helper_${JUSTVER}.crx
41 git commit . -m "$THEVER" --author='Galaxy <galaxy001@gmail.com>'
42 git push
43 echo "Updated: $THEVER"
44 else
45 echo "Still: $THEVER"