Subversion Repositories configs

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 - 1
#!/bin/bash
2
#
3
# ossec-hids      This shell script takes care of starting and stopping
4
#                 the OSSEC-HIDS daemon(s).
5
#
6
# chkconfig: 2345 99 15
7
# description:    OSSEC-HIDS is an Open Source Host-based Intrusion \
8
#                 Detection System.
9
# config: /etc/ossec-init.conf
10
 
11
# Source function library.
12
. /etc/rc.d/init.d/functions
13
 
14
# Source networking configuration.
15
. /etc/sysconfig/network
16
 
17
# Check that networking is up.
33 - 18
#[ ${NETWORKING} = "no" ] && exit 1
3 - 19
 
20
# Defines
21
DESC="the OSSEC HIDS"
22
NAME="ossec-hids"
23
PROG="ossec-control"
24
EXEC="/var/ossec/bin/${PROG}"
25
LOCK="/var/lock/subsys/${NAME}"
26
CONF="/etc/ossec/ossec.conf"
27
 
28
 
29
 
30
# Check for binaries and configs
31
[ -x /var/ossec/bin/ossec-control ] && {
32
  OSSEC=/var/ossec/bin/ossec-control
33
  SHORT=ossec-hids
34
}
35
[ -z "$OSSEC" ] && exit 1
36
[ -r /etc/ossec-init.conf ] || exit 1
37
 
38
 
39
start() {
40
	# Start daemons.
41
	echo -n $"Starting $SHORT: "
42
	#initlog -q -c "$OSSEC start"
43
	$OSSEC start > /dev/null
44
	RETVAL=$?
45
 
46
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SHORT
47
 
48
	[ $RETVAL -eq 0 ] && success $"$SHORT startup" || failure $"$SHORT startup"
49
	echo
50
	return $RETVAL
51
}
52
 
53
stop() {
54
	# Stop daemons.
55
	echo -n $"Shutting down $SHORT: "
56
	#initlog -q -c "$OSSEC stop"
57
	$OSSEC stop > /dev/null
58
	RETVAL=$?
59
 
60
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SHORT
61
 
62
	[ $RETVAL -eq 0 ] && success $"$SHORT shutdown" || failure $"$SHORT shutdown"
63
	echo
64
	return $RETVAL
65
}
66
 
67
 
68
rh_status() {
69
        LANG=C LC_ALL=C ${EXEC} status
70
 
71
        # We need the right status return value from at least one common process,
72
        # otherwise the startup check for already running processes won't work.
73
        status ossec-execd >/dev/null
74
}
75
 
76
rh_status_q() {
77
        rh_status >/dev/null 2>&1
78
}
79
 
80
 
81
 
82
 
83
restart() {
84
	stop
85
	sleep 10
86
	start
87
}
88
 
89
# This is a special condition used by ASL
90
reload() {
91
        # Stop daemons.
92
        echo -n $"Reloading $SHORT: "
93
        #initlog -q -c "$OSSEC stop"
94
        $OSSEC reload > /dev/null
95
        RETVAL=$?
96
 
97
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SHORT
98
 
99
        [ $RETVAL -eq 0 ] && success $"$SHORT reload" || failure $"$SHORT reload"
100
        echo
101
        return $RETVAL
102
 
103
	start
104
 
105
}
106
 
107
 
108
 
109
# See how we were called.
110
case "$1" in
111
	start)
112
	  start
113
	  ;;
114
	stop)
115
	  stop
116
	  ;;
117
	status)
118
	  rh_status
119
	  ;;
120
	restart)
121
	  restart
122
	  ;;
123
	condrestart)
124
	  if [ -e /var/lock/subsys/$SHORT ]; then restart; fi
125
	  ;;
126
	reload)
127
	  reload
128
	  ;;
129
	*)
130
	  echo $"Usage: ossec-hids {start|stop|status|restart|condrestart|reload}"
131
	  exit 1
132
esac
133
 
134
exit $RETVAL
135