○ vsftpd起動スクリプト

*vsftpd-2.3.2で使っています
*複数のconfファイルを読み込んで、複数のデーモンが起動します
*完全コピーしないこと (エラーが出ることあり)
*CentOSのvsftpd起動スクリプトを参考にしています

*"#" で始まる行はコメントとして解釈され、"$" の付いた文字は変数を表します
*スクリプトの先頭で, 処理を行うシェルを明示します (#!/bin/bash)
*# chkconfig: の#のあとに半角スペース
*# description: の#のあとに半角スペース
*. /  . はファイルを読み込むコマンド 後に半角スペース
*[ ] はテストコマンドです 半角スペースを忘れないように
*[ = ] テストコマンド内は = の前後に半角スペース
*環境変数等価式=の場合、前後に半角スペースをいれない
*A && B Aが正ならばBを実効
*A || B Aが為ならばBを実効
*$0 はスクリプト本体 $1は 第1引数

○/etc/rc.d/init.d/vsftpd

#!/bin/bash
#
# vsftpd    This shell script takes care of starting and stopping
#           standalone vsftpd.
#
# chkconfig: 235 60 50
# description: Vsftpd is a ftp daemon, which is the program \
#              that answers incoming ftp service requests.
# processname: vsftpd
# config: /etc/vsftpd/vsftpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
[ -x /usr/local/sbin/vsftpd ] || exit 0

RETVAL=0
prog="vsftpd"

start() {
    # Start daemons.
    if [ -d /etc/vsftpd ] ; then
        for i in `ls /etc/vsftpd/*.conf`; do
            site=`basename $i .conf`
            echo -n $"Starting $prog for $site: "
            /usr/local/sbin/vsftpd $i &
            RETVAL=$?
            [ $RETVAL -eq 0 ] && {
                touch /var/lock/subsys/$prog
                success $"$prog $site"
            }
            echo
        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}"
        exit 1
esac

exit $RETVAL

vsftpd

○ Copyright(c) 528p.com All Rights Reserved.