#!/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;;
*)
文档更新时间: 2018-12-12 20:52 作者:张尚