最近在弄heartbeat crm模式,由于crm模式要一定要OCF或LSB的启动脚本,没办法只能自己动手写了:
#! /bin/bash
# chkconfig: - 67 19
# description: Nginx Web Server
. /etc/rc.d/init.d/functions
nginxconf=/usr/local/nginx/conf/nginx.conf
nginxpid=/usr/local/nginx/logs/nginx.pid
nginxd=/usr/local/nginx/sbin/nginx
RETVAL=0
prog=nginx
if test -e $nginxd && test -e $nginxconf
then
echo OK > /dev/null
else
echo "$nginxd or $nginxconf was miss please check it!"
exit 1
fi
if test -x $nginxd
then
echo ok > /dev/null
else
echo "$nginxd Permission deny"
exit
fi
function nginxstart {
if test -e $nginxpid
then
echo "The nginx is already running!"
exit
else
echo -n $"Starting $prog:"
daemon $nginxd
RETVAL=$?
echo ""
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nginx
fi
}
function nginxstop {
echo -n $"Stopping $prog:"
killproc $nginxd
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -rf /var/lock/subsys/nginx
echo ""
}
function nginxreload {
echo -n $"Reloading $prog:"
echo ""
$nginxd -t
if test $? != 0
then
exit
else
killproc $nginxd -HUP
echo ""
fi
}
case "$1" in
start)
nginxstart
RETVAL=$?
;;
status)
status $nginxd
RETVAL=$?
;;
stop)
nginxstop
RETVAL=$?
;;
restart)
nginxstop
nginxstart
RETVAL=$?
;;
reload)
nginxreload
RETVAL=$?
;;
test)
$nginxd -t
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|restart|test}"
esac
exit $RETVAL
完成!
阅读(979) | 评论(0) | 转发(0) |