#!/usr/bin/sh
# Helper script to provide legacy auditd service options not 
# directly supported by systemd

# Check that we are root ... so non-root users stop here
test "$(id -u)" = "0"  ||  exit 4

printf "Stopping logging: "
PATH=/sbin:/bin:/usr/bin:/usr/sbin
prog="auditd"
pid=
p=$(pidof "$prog")
if [ -n "$p" ] ; then
	pid="$p"
fi

/sbin/auditctl --signal stop
RETVAL=$?
if [ -n "$pid" -a $RETVAL -eq 0 ] ; then
    # Wait up to 20 seconds for auditd to shutdown
    timeout 20 tail --pid="$pid" -f /dev/null
fi
echo
exit $RETVAL
