○ portsentry起動スクリプト

*portsentry-1.2を自動起動するスクリプトです

*"#" で始まる行はコメントとして解釈され、"$" の付いた文字は変数を表します
*スクリプトの先頭で, 処理を行うシェルを明示します (#!/bin/bash)
*# chkconfig: の#のあとに半角スペース
*# description: の#のあとに半角スペース
*. /  . はファイルを読み込むコマンド 後に半角スペース
*環境変数等価式=の場合、前後に半角スペースをいれない
*$0 はスクリプト本体 $1は 第1引数
*ユーザ・オーナー・パーミッション (root root 700)

○/etc/rc.d/init.d/portsentry

#!/bin/bash
#
# portsentry Start the portsentry portscan detector
#
# chkconfig: 345 98 05
# description: PortSentry Port Scan Detector is part of the Abacus Project \
#              suite of tools. The Abacus Project is an initiative to release \
#              low-maintenance, generic, and reliable host based intrusion \
#              detection software to the Internet community.
# processname: portsentry
# configfile: /usr/local/portsentry/portsentry.conf
# pidfile: /var/run/portsentry.pid

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

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

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

# For this script to work on non english systems
export LANG=C

SENTRYDIR="/usr/local/portsentry"

RETVAL=0

start() {
    # Check for modes defined in the config file
    if [ -s $SENTRYDIR/portsentry.modes ] ; then
        modes=`cut -d "#" -f 1 $SENTRYDIR/portsentry.modes`
    else
        modes="tcp udp"
    fi
    for i in $modes ; do
        action $"Starting portsentry -$i: " $SENTRYDIR/portsentry -$i
        RETVAL=$?
    done
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/portsentry
    return $RETVAL
}

stop() {
    echo -n $"Stopping portsentry: "
    killproc portsentry
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/portsentry
    return $RETVAL
}

# See how we were called.
case $1 in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status portsentry
        RETVAL=$?
        ;;
    restart)
        stop
        start
        RETVAL=$?
        ;;
    condrestart)
        if [ -f /var/lock/subsys/portsentry ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
    *)
        echo $"Usage: portsentry {start|stop|restart|condrestart|status}"
    exit 1
esac

exit $RETVAL

portsentry

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