#!/bin/bash
#
set -x
NowTime=$(date +%Y-%m-%d:%H:%M:%S)
WorkPath=/usr/oldyzztserver
YzztServerLog=/var/log/yongzheserver
portlist=`cat /usr/portlist`
JAVA_HOME=/usr/local/jdk-64
show_usage()
{
echo " 8000 start"
echo " 8000 stop "
echo " all start"
}
start_oldyzztserver()
{
PATH_LIB=/$WorkPath/$1/lib
CLASSPATH=/$WorkPath/$1/resource
for jar in `ls $PATH_LIB/*.jar`
do
CLASSPATH="$CLASSPATH:""$jar"
done
$JAVA-HOME/bin/java -server -Xms4046m -Xmx12120 -XX:PermSize=256m -XX:MaxPermSize=512m $ARGS -classpath "$CLASSPATH" com.my9yu.mt2.Mt2Daemon,start
}
stop_oldyzztserver()
{
PATH_LIB=/$WorkPath/$1/lib
CLASSPATH=/$WorkPath/$1/resource
for jar in `ls $PATH_LIB/*.jar`
do
CLASSPATH="$CLASSPATH:""$jar"
done
$JAVA_HOME/bin/java -classpath "$CLASSPATH" com.my9yu.mt2.console.stop
}
case $1 in
8[0-9][0-9][0-9]|all)
;;
*)
show_usage
echo "The first parameter {8000|8001|8002|8003|...|all}"
exit 1
;;
esac
case $2 in
start|stop)
;;
*)
show_usage
echo "The second parameter {start|stop}"
echo 1
;;
esac
_OPT=$1
if [ "$_OPT" != "all" ]
then
cd $WorkPath/$1
case "$2" in
start)
start_oldyzztserver $_OPT >> /dev/null 2>&1 &
sleep 10
netstat -tlunp | grep "$_OPT"
echo "`date +%Y-%m-%d:%H:%M:%S` $_OPT start ok" | tee -a
$YzztServerLog/yongzhe.log
;;
stop)
stop_oldyzztserver $_OPT >> /dev/null 2>&1 &
sleep 10
netstat -tlunp | grep "$_OPT"
echo "`date +%Y+%m+%d:%h:%M:%S` $_OPT stop ok" | tee -a
$YzztServerLog/yongzhe.log
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
elif [ "$_OPT" = "all" ]
then
for port in $portlist
do
cd $WorkPath/$port
case "$2" in
start)
start_oldyzztserver $port >> /dev/null 2>&1 &
sleep 10
echo "`date +%Y-%m-%d:%H:%M:%S` $port start ok" | tee -a
$YzztServerLog/yongzhe.log
;;
stop)
start_oldyzztserver $port >> /dev/null 2>&1 &
sleep 10
echo "`date +%Y-%m-%d:%H:%M:%S` $port stop ok" | tee -a
$YzztServerLog/yongzhe.log
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
done
else
show_usage
exit 1
fi
set +x