- #!/bin/bash
- # chkconfig: 345 99 99
- # description: this is a testsrv
- . /etc/init.d/functions
- lockfile=/var/lock/subsys/$0
- start(){
- if [ -e $lockfile ] ; then
- action "$0 is running"
- else
- touch $lockfile
- if [ "$?" -eq 0 ] ; then
- action "$0 start"
- else
- action "$0 failed" false
- fi
- fi
- }
- stop(){
- if [ -e $lockfile ] ; then
- rm -rf $lockfile
- if [ "$?" -eq 0 ] ; then
- action "$0 stop"
- else
- action "$0 stop failed" false
- fi
- else
- action "$0 is stoped"
- fi
- }
- restart(){
- start
- stop
- }
- status(){
- if [ -e $lockfile ] ; then
- action "$0 running"
- else
- action "$0 stoped"
- fi
- }
- usage(){
- echo "$0 {start|stop|status|restart}"
- }
- case $1 in
- start)
- start;;
- stop)
- stop;;
- restart)
- restart;;
- status)
- status;;
- *)
posted @
2018-02-28 13:55
莫孟林
阅读(
135)
评论()
编辑
收藏
举报