4
# Required-Start: $remote_fs
5
# Required-Stop: $local_fs
6
# Default-Start: 2 3 4 5
8
# Short-Description: Audit Daemon
9
# Description: Collects audit information from Linux 2.6 Kernels.
12
# Author: Philipp Matthias Hahn <pmhahn@debian.org>
13
# Based on Debians /etc/init.d/skeleton and Auditds init.d/auditd.init
15
PATH=/sbin:/usr/sbin:/bin:/usr/bin
19
PIDFILE=/var/run/"$NAME".pid
20
SCRIPTNAME=/etc/init.d/"$NAME"
22
# Exit if the package is not installed
23
[ -x "$DAEMON" ] || exit 0
25
# Read configuration variable file if it is present
26
[ -r /etc/default/"$NAME" ] && . /etc/default/"$NAME"
28
# Define LSB log_* functions.
29
. /lib/lsb/init-functions
32
# Function that starts the daemon/service
37
# 0 if daemon has been started
38
# 1 if daemon was already running
39
# 2 if daemon could not be started
40
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null \
42
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec "$DAEMON" -- \
45
# Call augenrules to compile audit rules.
46
case "$USE_AUGENRULES" in
48
*) [ -d /etc/audit/rules.d ] && /sbin/augenrules >/dev/null ;;
50
if [ -f /etc/audit/audit.rules ]
52
/sbin/auditctl -R /etc/audit/audit.rules >/dev/null
57
# Function that stops the daemon/service
62
# 0 if daemon has been stopped
63
# 1 if daemon was already stopped
64
# 2 if daemon could not be stopped
65
# other if a failure occurred
66
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile "$PIDFILE" --name "$NAME"
68
[ "$RETVAL" = 2 ] && return 2
69
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$DAEMON"
70
[ "$?" = 2 ] && return 2
71
# Many daemons don't delete their pidfiles when they exit.
73
rm -f /var/run/audit_events
74
# Remove watches so shutdown works cleanly
75
case "$AUDITD_CLEAN_STOP" in
77
*) /sbin/auditctl -D >/dev/null ;;
79
# Disable audit system on daemon shutdown
80
case "$AUDITD_STOP_DISABLE" in
82
*) /sbin/auditctl -e 0 >/dev/null ;;
88
# Function that sends a SIGHUP to the daemon/service
91
start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE --name $NAME
97
log_daemon_msg "Starting $DESC" "$NAME"
100
0|1) log_end_msg 0 ;;
105
log_daemon_msg "Stopping $DESC" "$NAME"
108
0|1) log_end_msg 0 ;;
113
log_daemon_msg "Reloading $DESC" "$NAME"
118
log_daemon_msg "Restarting $DESC" "$NAME"
125
1) log_end_msg 1 ;; # Old process is still running
126
*) log_end_msg 1 ;; # Failed to start
136
log_daemon_msg "Rotating $DESC logs" "$NAME"
137
start-stop-daemon --stop --signal USR1 --quiet --pidfile "$PIDFILE" --name "$NAME"
141
pidofproc -p "$PIDFILE" "$DAEMON" >/dev/null
143
if [ $status -eq 0 ]; then
144
log_success_msg "$NAME is running."
146
log_failure_msg "$NAME is not running."
151
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|rotate|status}" >&2