Files
smarttms-rpm-build/rpmbuild/BUILD/smarttms-1.0/smarttms
2025-12-05 21:28:39 +08:00

104 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
#chkconfig: 2345 80 05
#description: SmartTMS
source /etc/profile
RETVAL=0;
user=`whoami`;
username="";
tomcatversion="";
startall() {
if [ "$user" != "root" ]; then
echo -e "\033[31;5;5mPermission denied, please use the root user!\033[0m";
exit 2;
fi
if [ -n "`netstat -anp|grep -n '.*:8443.*java'`" ]; then
echo -e "\033[31;5;5mYou can't Repeated start smarttms;SmartTMS is running...\033[0m";
exit 2;
fi
echo -e "[\033[34;5;5mStarting smartTMS-DB...\033[0m]";
service mysqld start;
echo -e "[\033[34;5;5mStarting smartTMS-LMS...\033[0m]";
service proftpd start;
echo -e "[\033[34;5;5mStarting smartTMS-Server...\033[0m]";
setsid /home/smart/.tms3/apache-tomcat-7.0.63/bin/startup.sh;
echo -e "[\033[32;5;5mSmartTMS started.\033[0m]";
}
stopall() {
if [ "$user" != "root" ]; then
echo -e "\033[31;5;5mPermission denied, please use the root user!\033[0m";
exit 2;
fi
echo -e "[\033[34;5;5mStopping smartTMS-Server...\033[0m]";
/home/smart/.tms3/apache-tomcat-7.0.63/bin/shutdown.sh;
sleep 10;
kill -9 `netstat -tlnp | grep ":8443 " | awk '{print $7}' | awk -F '/' '{print $1}'`;
kill -9 `netstat -tlnp | grep ":162 " | awk '{print $7}' | awk -F '/' '{print $1}'`;
echo -e "Stopping smartTMS-Server [\033[32;5;5m OK \033[0m]";
echo -e "[\033[34;5;5mStopping smartTMS-DB...\033[0m]";
service mysqld stop;
echo -e "[\033[34;5;5mStopping smartTMS-LMS...\033[0m]";
service proftpd stop;
echo -e "[\033[32;5;5mSmartTMS stoped.\033[0m]";
}
start() {
if [ -n "`netstat -anp|grep -n '.*:8443.*java'`" ]; then
echo -e "\033[31;5;5mYou can't Repeated start smarttms;SmartTMS is running...\033[0m";
exit 2;
fi
echo -e "[\033[34;5;5mStarting smartTMS-Server...\033[0m]";
setsid /home/smart/.tms3/apache-tomcat-7.0.63/bin/startup.sh;
echo -e "[\033[32;5;5mSmartTMS started.\033[0m]";
}
stop() {
ps -ef|grep [j]ava|grep tomcat|awk '{print $2}'|while read pid
do
kill -9 $pid
done
}
case $1 in
start)
start
;;
stop)
stop
;;
status)
if [ -z "`netstat -anp|grep -n '.*:8443.*java'`" ]; then
echo "SmartTMS is running...";
else
echo "SmartTMS is stopped";
fi
;;
restart)
stop
start
;;
startall)
startall
;;
stopall)
stopall
;;
statusall)
if [ -z "`netstat -anp|grep -n '.*:8443.*java'`" ]; then
echo "SmartTMS is running...";
else
echo "SmartTMS is stopped";
fi
;;
restartall)
stopall
startall
;;
*)
;;
esac