#!/bin/bash
#
#	/etc/rc.d/init.d/distcc
#
# Starts the distccd daemon
#
# WARNING: Don't enable on untrusted networks
#
# chkconfig: - 80 20
# description: Start the distcc daemon
# processname: distccd
#

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

OPTIONS=--daemon
USER=nobody

RETVAL=0
prog="distccd"

[ -x /usr/bin/distccd ] || exit 0

start() {
	echo -n "Starting $prog"
	daemon --user $USER $prog $OPTIONS
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
	echo -n "Shutting down $prog"
	killproc $prog
	RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status $prog
		RETVAL=$?
		;;
	restart|reload)
		stop
		start
		RETVAL=$?
		;;
	condrestart)
		if [ -f /var/lock/subsys/$prog ]; then
			stop
			start
			RETVAL=$?
		fi
		;;
	*)
		echo $"Usage $0 {start|stop|restart|condrestart|status}"
		exit 1
esac

exit $RETVAL

