4 # Required-Start: $local_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 # June, 2012: Adopted for yocto <amy.fong@windriver.com>
17 # PATH should only include /usr/* if it runs after the mountnfs.sh script
18 PATH=/sbin:/bin:/usr/sbin:/usr/bin
22 PIDFILE=/var/run/"$NAME".pid
23 SCRIPTNAME=/etc/init.d/"$NAME"
25 # Exit if the package is not installed
26 [ -x "$DAEMON" ] || exit 0
28 # Read configuration variable file if it is present
29 [ -r /etc/default/"$NAME" ] && . /etc/default/"$NAME"
33 . /etc/init.d/functions
36 # Function that starts the daemon/service
41 # 0 if daemon has been started
42 # 1 if daemon was already running
43 # 2 if daemon could not be started
44 start-stop-daemon -S --quiet --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null \
46 start-stop-daemon -S --quiet --pidfile "$PIDFILE" --exec "$DAEMON" -- \
49 if [ -f /etc/audit/audit.rules ]
51 /sbin/auditctl -R /etc/audit/audit.rules >/dev/null
56 # Function that stops the daemon/service
61 # 0 if daemon has been stopped
62 # 1 if daemon was already stopped
63 # 2 if daemon could not be stopped
64 # other if a failure occurred
65 start-stop-daemon -K --quiet --pidfile "$PIDFILE" --name "$NAME"
67 [ "$RETVAL" = 2 ] && return 2
68 # Many daemons don't delete their pidfiles when they exit.
70 rm -f /var/run/audit_events
71 # Remove watches so shutdown works cleanly
72 case "$AUDITD_CLEAN_STOP" in
74 *) /sbin/auditctl -D >/dev/null ;;
80 # Function that sends a SIGHUP to the daemon/service
83 start-stop-daemon -K --signal HUP --quiet --pidfile $PIDFILE --name $NAME
87 if [ ! -e /var/log/audit ]; then
88 mkdir -p /var/log/audit
89 [ -x /sbin/restorecon ] && /sbin/restorecon -F /var/log/audit
94 [ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME"
97 0|1) [ "$VERBOSE" != no ] && echo 0 ;;
98 2) [ "$VERBOSE" != no ] && echo 1 ;;
102 [ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME"
105 0|1) [ "$VERBOSE" != no ] && echo 0 ;;
106 2) [ "$VERBOSE" != no ] && echo 1 ;;
110 echo "Reloading $DESC" "$NAME"
115 echo "Restarting $DESC" "$NAME"
122 1) echo 1 ;; # Old process is still running
123 *) echo 1 ;; # Failed to start
133 echo "Rotating $DESC logs" "$NAME"
134 start-stop-daemon -K --signal USR1 --quiet --pidfile "$PIDFILE" --name "$NAME"
138 pidofproc "$DAEMON" >/dev/null
140 if [ $status -eq 0 ]; then
141 echo "$NAME is running."
143 echo "$NAME is not running."
148 echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|rotate|status}" >&2