Files
keeprunningd/services/keeprunning-service

86 lines
1.8 KiB
Bash

#!/bin/bash
# chkconfig: 2345 90 10
# description: start or stop the keeprunning-service server
#
### BEGIN INIT INFO
# Provides: keeprunning-service
# Required-Start: $network $syslog $local_fs $remote_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start or stop the keeprunning-service server
### END INIT INFO
# Author: hatter <https://playsecurity.org/>
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
name=keeprunning-service
install_path=/keeprunning-service/
fnname=keeprunningd
logname=${install_path}service.log
[[ -s "/java-env-init.sh" ]] && source "/java-env-init.sh"
[[ -s "${install_path}env-init.sh" ]] && source "${install_path}env-init.sh"
start(){
ulimit -s 65535
ulimit -n 65535
$install_path$fnname > $logname 2>&1 &
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
echo "$name start success"
else
echo "$name start failed"
fi
}
stop(){
pid=`ps -ef | grep $fnname | grep -v grep | awk '{print $2}'`
if [[ ! -z $pid ]]; then
ps -ef | grep $fnname | grep -v grep | awk '{print $2}' | xargs kill -s 9
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
echo "$name stop success"
else
echo "$name stop failed"
fi
else
echo "$name is not running"
RETVAL=1
fi
}
status(){
pid=`ps -ef | grep $fnname | grep -v grep | awk '{print $2}'`
if [[ -z $pid ]]; then
echo "$name is not running"
RETVAL=1
else
echo "$name is running with PID $pid"
RETVAL=0
fi
}
case "$1" in
'start')
stop
start
;;
'stop')
stop
;;
'status')
status
;;
'restart')
stop
start
RETVAL=$?
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL