Chinaunix首页 | 论坛 | 博客
  • 博客访问: 450367
  • 博文数量: 135
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 1145
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-13 17:16
文章分类

全部博文(135)

文章存档

2011年(5)

2010年(4)

2009年(26)

2008年(25)

2007年(29)

2006年(42)

2005年(4)

分类:

2009-02-05 10:01:30

花了一天的时间看了一下,顺便自已也写了一个,记录一下。
人比较懒,只写了一些比较容易出问题的地方.
如果不明白的地方,可以一起讨论。
文件: Deamon.zip
大小: 115KB
下载: 下载
 

启动脚本都放置在/etc/init.d目录下

主要有:start  ,stop   ,restart   ,status 其它部份可以跟据需求增加

#!/bin/bash

#要chkconfig必须要这两行,就是必须要这个注释

chkconfig:- 60 50

60是启动优先级,50是停止服务优先级."-"代表着那个启动项可以启动服务"1,2,3,4,5,6"

# chkconfig: - 60 50

# description: Vsftpd is a ftp daemon, which is the program \

#              that answers incoming ftp service requests.

# Source function library.

. /etc/rc.d/init.d/functions

 

# Source networking configuration.

. /etc/sysconfig/network

RETVAL=0

prog="vsftpd-pam"

# 主要是写start stop两块,其它的部分不用管

start() {

        # Check that networking is up.

        [ "${NETWORKING}" = "no" ] && exit 1

        [ -x /usr/local/sbin/vsftpd-pam ] || exit 1

        if [ -x /usr/local/sbin/vsftpd-pam ];

        then

                CONFS=`ls /etc/vsftpd-pam.conf 2>/dev/null`

                [ -z $CONFS ] && exit 6

                for i in $CONFS; do

                        echo -n $"Starting $prog for $site: "

                        daemon /usr/Local/sbin/vsftpd-pam $i &

                        RETVAL=$?

                        #这里的返回值为0时是正常的,错误的值为127

                        echo

                        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog

                done

        else

                RETVAL=1

        fi

        return $RETVAL

}

stop() {

        # Stop daemons.

        echo -n $"Shutting down $prog: "

        killproc $prog

        RETVAL=$?

        echo

        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog

        return $RETVAL

}

# See how we were called.

case "$1" in

  start)

        start

        ;;

  stop)

        stop

        ;;

  restart|reload)

        stop

        start

        RETVAL=$?

        ;;

  condrestart)

        if [ -f /var/lock/subsys/$prog ]; then

            stop

            start

            RETVAL=$?

        fi

        ;;

  status)

        status $prog

        RETVAL=$?

        ;;

  *)

        echo $"Usage: $0 {start|stop|restart|condrestart|status}"

阅读(597) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~