Hunter的大杂烩 技术学习笔记

2012-06-26

发布脚本[1]

Filed under: 技术话题 — hunter @ 4:39 pm

#!/bin/sh

if [ $# -lt 2 ];then
        echo “USAGE: $0 check (css|js|images|open|swf|jsp|cms)”
        echo “USAGE: $0 pub pubfile”
        echo “USAGE: $0 clean all”
        exit
fi


if [ $1 = “pub” ];then
        pubfile=$2
        if [ ! -f $pubfile ];then
                echo “file not found:”$pubfile
                exit
        fi
        fs=`/usr/bin/filesize ${pubfile}`
        if [ $fs -lt 1 ];then
                echo “file empty:”$fs
                exit
        fi
        fileline=`head -n 1 $pubfile`
        action=`echo $fileline|awk -F’/’ ‘{print $1}’`
        if [ $action = “WEB-INF” ];then
                echo “rsync –files-from=$pubfile -va  /data/${acc}/svndata/index/ /data/${acc}/app/webapps/mysite/ ”
                rsync –files-from=$pubfile -va  /data/${acc}/svndata/index/ /data/${acc}/app/webapps/mysite/
        else
                echo “rsync –files-from=$pubfile -vna  /data/${acc}/svndata/index/ /data/${acc}/app/htdocs/ ”
                rsync –files-from=$pubfile -va  /data/${acc}/svndata/index/ /data/${acc}/app/htdocs/
        fi
elif [ $1 = “check” ];then
        action=$2
        time_posfix=`date +%s`
        if [ $action = “css” ];then
                rsync -inac  /data/${acc}/svndata/index/css /data/${acc}/app/htdocs/ |egrep “^>”|awk ‘{print $2}’ > /data/${acc}/log/pubfile.$time_posfix
        elif [ $action = “maishi” ];then
                rsync -inac  /data/${acc}/svndata/index/WEB-INF /data/${acc}/app/webapps/mysite/ |egrep “^>” |awk ‘{print $2}’ > /data/${acc}/log/pubfile.$time_posfix
        fi
       echo “file should transfer:”
        cat /data/${acc}/log/pubfile.${time_posfix}
        echo
        echo “file save:/data/${acc}/log/pubfile.${time_posfix}”
elif [ $1 = “clean” ];then
        rm /data/${acc}/log/pubfile.*
fi

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress