Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > main-src > by-pkgid > bd5d048234b116cb35bd4a8713476629 > files > 2

prelude-0.4.2-6mdk.src.rpm

#!/bin/sh
#
# prelude		This shell script takes care of starting and stopping
#				prelude.
#
# chkconfig: 2345 80 30
#
# description: Prelude is a Network Intrusion Detection System.

# 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/bin/prelude ] || exit 0

if [ -z "${NET_DEVICE}" ]; then
    if [ -r /etc/sysconfig/network-scripts/draknet_conf ]; then

	. /etc/sysconfig/network-scripts/draknet_conf

	if [ "$InternetAccessType" != lan ]; then
	    NET_DEVICE=$InternetInterface
	else
	    NET_DEVICE=${GATEWAYDEV=eth0}
	fi
    else
	NET_DEVICE=${GATEWAYDEV=eth0}
    fi
fi

[ -z "${NET_DEVICE}" ] && exit 0

# See how we were called.
case "$1" in
  start)
        # check if the link is up before starting prelude
        . /etc/sysconfig/network-scripts/network-functions

        check_device_down ${NET_DEVICE} && exit 0
	
	# Start daemons.
        if [ -x /usr/bin/prelude_report ]; then
	    echo -n "Starting prelude report: "
	    daemon /usr/bin/prelude_report -qd -P "/var/run/prelude_report.pid"
	    touch /var/lock/subsys/prelude_report
	    echo
	fi
	echo -n "Starting prelude: "
	daemon /usr/bin/prelude -qd -P "/var/run/prelude.pid" -i ${NET_DEVICE}
	RETVAL=$?
	echo 
	touch /var/lock/subsys/prelude
	;;

  stop)
	echo -n "Shutting down prelude: "
	killproc prelude
	RETVAL=$?
	echo 
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/prelude

        if [ -x /usr/bin/prelude_report -a -f /var/lock/subsys/prelude_report ]; then
	    echo -n "Shutting down prelude report: "
	    killproc prelude_report
	    RET=$?
	    echo 
	    [ $RET -eq 0 ] && rm -f /var/lock/subsys/prelude_report
	fi
	;;

  restart)
	$0 stop
	exec $0 start
	;;

  reload)
  	$0 restart
	;;

  status)
	status prelude
        if [ -x /usr/bin/prelude_report ]; then
	    status prelude_report
	fi
	;;
	
  *)
	echo "Usage: $0 {start|stop|restart|reload|status}"
	exit 1
esac

exit $RETVAL