kstart/k5start start-up script

I've recently been working with k5start on a RHEL 5 client and noticed that it lacked a start-up script. As usual, it seems such a waste for me to write one and not share it with everyone else, so for those who may also need this at some point in the future:

#!/bin/bash
#
# k5start:      Keeps Kerberos 5 ticket-granting ticket active indefinitely
# Author:       Mark R. Bannister <cambridge@users.sourceforge.net>
#
# chkconfig: 345 19 74
# description:  Keeps Kerberos 5 ticket-granting ticket active indefinitely
#
# processname: /usr/bin/k5start
# config: /etc/krb5.conf
# pidfile: /var/run/k5start.pid

# Sanity checks.
[ -f /etc/krb5.conf ] || exit 0
[ -x /usr/bin/k5start ] || exit 0

# Source function library.
. /etc/init.d/functions

K5START_KEYTAB=/etc/krb5.keytab
K5START_MINUTES=30
K5START_OPTIONS=

# Source an auxiliary options file if we have one
# This can override K5START_KEYTAB, K5START_MINUTES and K5START_OPTIONS
# It can also set DAEMON_COREFILE_LIMIT and NICELEVEL
[ -r /etc/sysconfig/k5start ] && . /etc/sysconfig/k5start

RETVAL=0

start() {
    echo -n $"Starting k5start: "
    daemon /usr/bin/k5start -f $K5START_KEYTAB -bLK$K5START_MINUTES \
                        -p /var/run/k5start.pid $K5START_OPTIONS -U
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/k5start
    return $RETVAL
}

stop() {
    echo -n $"Stopping k5start: "
    killproc -p /var/run/k5start.pid k5start
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/k5start
    echo
    return $RETVAL
}

restart() {
    stop
    start
}

# See how we were called.
case "$1" in
    start)
        start
        RETVAL=$?
        ;;
    stop)
        stop
        RETVAL=$?
        ;;
    status)
        status -p /var/run/k5start.pid k5start
        RETVAL=$?
        ;;
    restart)
        restart
        RETVAL=$?
        ;;
    try-restart | condrestart)
        [ -e /var/lock/subsys/k5start ] && restart
        RETVAL=$?
        ;;
    force-reload | reload)
        echo -n $"Refreshing k5start ticket cache: "
        killproc /usr/bin/k5start -ALRM
        RETVAL=$?
        echo
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
        RETVAL=1
        ;;
esac
exit $RETVAL

If you find that the k5start process is dying, you'll either need a root cron job to do /etc/init.d/k5start restart at intervals, or you can follow the advice in this posting and use respawn in /etc/inittab.

Best regards,
Mark.