Rev 3 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bash## ossec-hids This shell script takes care of starting and stopping# the OSSEC-HIDS daemon(s).## chkconfig: 2345 99 15# description: OSSEC-HIDS is an Open Source Host-based Intrusion \# Detection System.# config: /etc/ossec-init.conf# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.#[ ${NETWORKING} = "no" ] && exit 1# DefinesDESC="the OSSEC HIDS"NAME="ossec-hids"PROG="ossec-control"EXEC="/var/ossec/bin/${PROG}"LOCK="/var/lock/subsys/${NAME}"CONF="/etc/ossec/ossec.conf"# Check for binaries and configs[ -x /var/ossec/bin/ossec-control ] && {OSSEC=/var/ossec/bin/ossec-controlSHORT=ossec-hids}[ -z "$OSSEC" ] && exit 1[ -r /etc/ossec-init.conf ] || exit 1start() {# Start daemons.echo -n $"Starting $SHORT: "#initlog -q -c "$OSSEC start"$OSSEC start > /dev/nullRETVAL=$?[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SHORT[ $RETVAL -eq 0 ] && success $"$SHORT startup" || failure $"$SHORT startup"echoreturn $RETVAL}stop() {# Stop daemons.echo -n $"Shutting down $SHORT: "#initlog -q -c "$OSSEC stop"$OSSEC stop > /dev/nullRETVAL=$?[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SHORT[ $RETVAL -eq 0 ] && success $"$SHORT shutdown" || failure $"$SHORT shutdown"echoreturn $RETVAL}rh_status() {LANG=C LC_ALL=C ${EXEC} status# We need the right status return value from at least one common process,# otherwise the startup check for already running processes won't work.status ossec-execd >/dev/null}rh_status_q() {rh_status >/dev/null 2>&1}restart() {stopsleep 10start}# This is a special condition used by ASLreload() {# Stop daemons.echo -n $"Reloading $SHORT: "#initlog -q -c "$OSSEC stop"$OSSEC reload > /dev/nullRETVAL=$?[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SHORT[ $RETVAL -eq 0 ] && success $"$SHORT reload" || failure $"$SHORT reload"echoreturn $RETVALstart}# See how we were called.case "$1" instart)start;;stop)stop;;status)rh_status;;restart)restart;;condrestart)if [ -e /var/lock/subsys/$SHORT ]; then restart; fi;;reload)reload;;*)echo $"Usage: ossec-hids {start|stop|status|restart|condrestart|reload}"exit 1esacexit $RETVAL