#!/bin/bash
user=game
tomcat=bi_log_gate_tomcat7
war_name=loggate.war
war_file=bi_log_gate
_time=`date +%Y%m%d-%H%M%S`

name=$(whoami)
case "$name" in
  "$user")
  _pid=`ps -ef | grep $tomcat | grep Djava | awk '{print $2}' `
  if [ "${_pid}k" != "k" ];then
    kill -s 9 ${_pid}
    sleep 5
  fi  
  cd /export/$tomcat
  mkdir -p  backup  &&  mv -f $war_file/$war_name backup/${war_name}.${_time}
  /bin/rm -rf $war_file/* webapps/* work/*
  /bin/cp -f $war_name $war_file/
  md5sum  /export/$tomcat/$war_file/$war_name
  bash bin/startup.sh
  ;;
  *)
  echo "user error"
  ;;
esac
