#!/bin/sh
if [ $# -lt 2 ];then
echo “USAGE: $0 pub pubfile”
echo “USAGE: $0 check (css|js|images|open|swf|maishi|cms)”
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 -e ‘ssh -l${remote_user} -q -p${remote_port}’ -vna /data/${acc}/app/webapps/mysite/ ${ip}:/data/${acc}/webapps/mysite/”
rsync –files-from=$pubfile -e ‘ssh -l${remote_user} -q -p${remote_port}’ -va /data/${acc}/app/webapps/mysite/ ${ip}:/data/${acc}/webapps/mysite/
else
echo “rsync –files-from=$pubfile -vna -e ‘ssh -l${remote_user} -q -p${remote_port}’ /data/${acc}/app/htdocs/ ${ip}:/data/${acc}/htdocs/”
rsync –files-from=$pubfile -va -e ‘ssh -l${remote_user} -q -p${remote_port}’ /data/${acc}/app/htdocs/ ${ip}:/data/${acc}/htdocs/
fi
elif [ $1 = “check” ];then
action=$2
time_posfix=`date +%s`
if [ $action = “css” ];then
rsync -inac -e ‘ssh -l${remote_user} -q -p${remote_port}’ /data/${acc}/app/htdocs/css ${ip}:/data/${acc}/htdocs/ |egrep “^< "|awk '{print $2}' > /data/${acc}/log/pubfile.$time_posfix
elif [ $action = “jsp” ];then
rsync –exclude=logs -inac -e ‘ssh -l${remote_user} -q -p${remote_port}’ /data/${acc}/app/webapps/mysite/WEB-INF ${ip}:/data/${acc}/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