目前程序想搞自動發佈,考慮到jenkis佔用內容大,配置麻煩,因而誕生了這個腳本 web
#!/bin/bash
#make by liuuhaihua
#time 2014/7/17
#version 1.3
#upgrade the project
#################定義變量#######################
instance="tomcat_demo";
tomcat_progrm="/opt/tomcat_demo";
bak_dir="/mnt/bak";
target_home="/home/www";
################延時函數########################
function running(){
b=''
for ((i=0;i<=100;i+=2))
do
printf "progress:[%-50s]%d%%\r" $b $i
sleep 0.2
b=#$b
done
echo
}
echo "#############開始更新svn##############";
svn up; tomcatecho "############開始執行ant打包##############";
ant dist; bashecho "########開始殺死tomcat進程,請等候5秒####################" ;
ps aux | grep $instance | grep -v grep | awk '{print "kill ",$2|"bash"}' ;
running ;
ps aux | grep $instance | grep -v grep; appecho "###########開始備份###################";
mv ${tomcat_progrm}/webapps/TinyCMS.war ${bak_dir}/TinyCMS__$(date "+%Y%m%d_%H%M").war;
rm -rf ${tomcat_progrm}/webapps/TinyCMS* ; webappecho "#################開始部署程序###################";
cp ${target_home}/TinyCMS/dist/*.war ${tomcat_progrm}/webapps/TinyCMS.war svnecho "####重啓tomcat...." ;
echo ${tomcat_progrm}/bin/startup.sh ;
${tomcat_progrm}/bin/startup.sh; 函數echo "###########查看啓動日誌#########" ;
running;
tail -f ${tomcat_progrm}/logs/catalina.out ; 日誌