#!/bin/sh
# Helper script to provide legacy ksl-daemon service options not
# directly supported by systemd

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

PATH=/sbin:/bin:/usr/bin:/usr/sbin
prog="ksl-daemon"
pid_file_name=/var/run/$prog.pid
. /etc/rc.d/init.d/functions
pid="$(cat $pid_file_name)"

printf "Stopping logging: "
killproc -p $pid_file_name -s TERM
RETVAL=$?
if [ -n "$pid" ] ; then
    # Wait up to 20 seconds for ksl-daemon to shutdown
    timeout 20 tail --pid="$pid" -f /dev/null
fi
echo
exit $RETVAL
