Sophie

Sophie

distrib > Altlinux > 4.1 > i586 > by-pkgid > 8f31a105af4dc2cdf534484ce7d585e9 > files > 3

fprobe-ulog-1.1-alt4.src.rpm

#!/bin/sh
# fprobe-ulog	ULOG-based NetFlow sensor
#
# chkconfig: 345 13 89
# description:	ULOG-based NetFlow sensor
# processname: fprobe-ulog
# config: /etc/sysconfig/fprobe-ulog
# pidfile: /var/run/fprobe-ulog.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

# Directory to chroot to.
CHROOT_TO=/var/lib/fprobe-ulog

# User to run as. User must have permissions to write pidfile to
# ${CHROOT_TO}/
USER=_fprobe

CONFIG=/etc/sysconfig/fprobe-ulog
BIN=/usr/sbin/fprobe-ulog
PID=fprobe-ulog.pid
PIDFILE=/var/run/$PID
RETVAL=0

[ -x $BIN ] || exit 0
[ -f $CONFIG ] || exit 0
SourceIfNotEmpty $CONFIG

OPTIONS=""
test "x$MASK" != "x" && OPTIONS="$OPTIONS -U $MASK"
test "x$MASK" != "x" && OPTIONS="$OPTIONS -U $MASK"
test "x$SCAN_TIME" != "x" && OPTIONS="$OPTIONS -s $SCAN_TIME"
test "x$LIFE_TIME" != "x" && OPTIONS="$OPTIONS -g $LIFE_TIME"
test "x$IDLE_TIME" != "x" && OPTIONS="$OPTIONS -d $IDLE_TIME"
test "x$ACTIVE_TIME" != "x" && OPTIONS="$OPTIONS -e $ACTIVE_TIME"
test "x$NF_VERSION" != "x" && OPTIONS="$OPTIONS -n $NF_VERSION"
test "x$SRC_IP" != "x" && OPTIONS="$OPTIONS -a $SRC_IP"
test "x$CONV_RULES" != "x" && OPTIONS="$OPTIONS -X $CONV_RULES"
test "x$USE_FWMARK_AS_TOS" != "x" && OPTIONS="$OPTIONS -M"
test "x$BULK_SIZE" != "x" && OPTIONS="$OPTIONS -b $BULK_SIZE"
test "x$MEM_LIMIT_CACHE" != "x" && OPTIONS="$OPTIONS -m $MEM_LIMIT_CACHE"
test "x$QUEUE_LEN" != "x" && OPTIONS="$OPTIONS -q $QUEUE_LEN"
test "x$CAPTURE_BUFFER_SIZE" != "x" && OPTIONS="$OPTIONS -B $CAPTURE_BUFFER_SIZE"
test "x$REALTIME" != "x" && OPTIONS="$OPTIONS -r $REALTIME"
test "x$RATE_LIMIT" != "x" && OPTIONS="$OPTIONS -t $RATE_LIMIT"

test "x$CHROOT_TO" != "x" && OPTIONS="$OPTIONS -c $CHROOT_TO"
test "x$CHROOT_TO" != "x" && PIDFILE="$CHROOT_TO/$PID"

test "x$USER" != "x" && OPTIONS="$OPTIONS -u $USER"
test "x$VERBOSITY" != "x" && OPTIONS="$OPTIONS -v $VERBOSITY"
test "x$LOG" != "x" && OPTIONS="$OPTIONS -l $LOG"
test "x$COLLECTOR" != "x" && OPTIONS="$OPTIONS $COLLECTOR"
test "x$ARGS" != "x" && OPTIONS="$OPTIONS $ARGS"

start()
{
    status --pidfile "$PIDFILE" -- $BIN
    if [ $? -eq 1 ]; then
        rm -rf $PIDFILE
    fi
	start_daemon -- $BIN $OPTIONS
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" -- $BIN
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	restart
} 

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$PIDFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$PIDFILE" ]; then
			restart
		fi
		;;
	condreload)
		if [ -e "$PIDFILE" ]; then
			reload
		fi
		;;
	status)
		status --pidfile "$PIDFILE" -- $BIN
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL