cd bin
sleep 10
./startup.sh
sleep 3
/usr/bin/tail -100 $Project_name/logs/catalina.out
echo -e "\033[32m$Project_name重启成功\033[0m"
;;
backup)
cd $Project_name
before_num=`/bin/ls webapps_backup/ |wc -l`
`/bin/find -type d -name "webapps_[0-9]*" -mtime +10 | xargs rm -fr`
#echo $my_Back
if [ ! -d "$my_Back" ]; then
`/bin/mkdir -p $my_Back`
fi
/bin/cp -frp webapps $my_Back/webapps_$(/bin/date -d "today" +"%Y%m%d_%H%M")
after_num=`/bin/ls webapps_backup/ |wc -l`
if [ $after_num -eq $(($before_num+1)) ];then
echo -e "\033[32m$Project_name备份成功\033[0m"
else
echo -e "\033[31m$Project_name备份失败,请重新备份\033[0m"
fi
;;
rollback)
file_name=`/bin/ls -ltc $Project_name/$my_Back|sed -n 2p|awk '{print $8}'`
#echo "$Project_name/$my_Back/$file_name"
#echo $file_name
/bin/cp -frp $Project_name/$my_Back/$file_name $Project_name/$my_Back/webapps
/bin/cp -frp $Project_name/$my_Back/webapps $Project_name
rm -fr $Project_name/$my_Back/webapps
cd $Project_name
if ([ "`find ./ -maxdepth 1 -type d -cmin -1|sed -n 1p`" == './webapps' ]);then
echo -e "\033[32m$Project_name回滚成功\033[0m"
else
echo -e "\033[31m$Project_name回滚失败,请重新执行一次\033[0m"
fi