Chinaunix首页 | 论坛 | 博客
  • 博客访问: 53459
  • 博文数量: 14
  • 博客积分: 1445
  • 博客等级: 上尉
  • 技术积分: 175
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-14 22:30
文章分类

全部博文(14)

文章存档

2017年(5)

2011年(1)

2010年(8)

我的朋友

分类: LINUX

2010-09-14 23:48:06

 
最近在弄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
 
完成!
阅读(955) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~