[distcc] init.d and sysconfig files for distccd

Spiller, Patrick PSpiller at ballytech.com
Fri May 30 00:03:47 GMT 2008


I was setting up distcc for my OpenSuse 10.3 system and draw up the
following files:
/etc/sysconfig/distccd
	# Author: Patrick Spiller

	#
	## Type: integer(2:8)
	## Path: Applications/distccd
	## ServiceRestart: distccd
	## Default: ""
	#
	# Maximum number of jobs to run (leave blank for 2 more than the
number of CPUs on the machine).
	#
	DISTCCD_JOBS=""

	#
	## Type: integer(0:19)
	## Path: Applications/distccd
	## Default: 5
	#
	# Increment of the "nice" level for jobs to be run.
	#
	DISTCCD_NICE=5

	#
	## Type: integer(1024:49151)
	## Path: Applications/distccd
	## Default: 3632
	#
	# port for the daemon to listen on (default 3632)
	#
	DISTCCD_PORT="3632"

	#
	## Type: string
	## Path: Applications/distccd
	## Default: ""
	#
	# instruct the daemon to listen on the given IP address
	#
	DISTCCD_LISTEN=""

	#
	## Type: string
	## Path: Applications/distccd
	## Default: ""
	#
	# save the daemon process id to file
	#
	DISTCCD_PIDFILE=""

	#
	## Type: string
	## Path: Applications/distccd
	## Default: "nobody"
	#
	# change to this user if run as root
	#
	DISTCCD_USER="nobody"

	#
	## Type: string
	## Path: Applications/distccd
	## Default: "10.10.0.0/16"
	# 
	# allowed IP range (mandatory)
	#
	DISTCCD_ALLOW="10.10.0.0/16"

	#
	## Type: string
	## Path: Applications/distccd
	## Default: "/var/log/distccd"
	# 
	# file to log output to
	#
	DISTCCD_LOGFILE="/var/log/distccd"

	#
	## Type: string
	## Path: Applications/distccd
	## Default: ""
	#
	# severity of error included in log file
	#
	DISTCCD_LOGLEVEL=""

/etc/init.d/distccd.sh (yeah, I know the ".sh" should not be there)
	#! /bin/sh
	#
	# Author: Patrick Spiller
	#
	### BEGIN INIT INFO
	# Provides:          distccd
	# Required-Start:    $network $syslog $remote_fs
	# Required-Stop:
	# Default-Start:     3 5
	# Default-Stop:
	# Description:       distributed compiler daemon
	### END INIT INFO

	# Determine the base and follow a runlevel link name.
	base=${0##*/}
	link=${base#*[SK][0-9][0-9]}

	# Force execution if not called by a runlevel directory.
	test -x /usr/local/bin/distccd || exit 0

	. /etc/rc.status
	. /etc/sysconfig/distccd

	rc_reset
	case "$1" in
	    start)
	        echo -n "Starting Distributed Compiler Daemon"
	        maxjobs=""
	        if test -n "$DISTCCD_JOBS"; then
	            maxjobs="--jobs $DISTCCD_JOBS"
	        fi
	        nicelevel=""
	        if test -n "$DISTCCD_NICE"; then
	            nicelevel="--nice $DISTCCD_NICE"
	        fi
	        port=""
	        if test -n "$DISTCCD_PORT"; then
	            port="--port $DISTCCD_PORT"
	        fi
	        listen=""
	        if test -n "$DISTCCD_LISTEN"; then
	            listen="--listen $DISTCCD_LISTEN"
	        fi
	        pidfile=""
	        if test -n "$DISTCCD_PIDFILE"; then
	            pidfile="--pid-file $DISTCCD_PIDFILE"
	        fi

	        if test -z "$DISTCCD_USER"; then
	            DISTCCD_USER=nobody
	        fi
	        user="--user $DISTCCD_USER"

	        allow=""
	        if test -n "$DISTCCD_ALLOW"; then
	            allow="--allow $DISTCCD_ALLOW"
	        fi

	        if test -z "$DISTCCD_LOGFILE"; then
	            DISTCCD_LOGFILE=/var/log/distccd
	        fi
	        logfile="--log-file $DISTCCD_LOGFILE"
	        touch $DISTCCD_LOGFILE
	        chown $DISTCCD_USER:$DISTCCD_USER $DISTCCD_LOGFILE

	        loglevel=""
	        if test -n "$DISTCCD_LOGLEVEL"; then
	            loglevel="--log-level $DISTCCD_LOGLEVEL"
	        fi

		startproc /usr/local/bin/distccd --daemon $maxjobs
$nicelevel $port $listen $pidfile $user $allow $logfile $loglevel
		rc_status -v
		;;
	    stop)
		echo -n "Shutting down Distributed Compiler Daemon"
		killproc -TERM /usr/local/bin//distccd
		rc_status -v
		;;
	    restart)
		## If first returns OK call the second, if first or
		## second command fails, set echo return value.
		$0 stop; sleep 1  &&  $0 start
		rc_status
		;;
	    try-restart|condrestart)
	        ## Do a restart only if the service was active before.
	        ## Note: try-restart is now part of LSB (as of 1.9).
	        ## RH has a similar command named condrestart.
	        if test "$1" = "condrestart"; then
	                echo "${attn} Use try-restart
${done}(LSB)${attn} rather than condrestart ${warn}(R
	H)${norm}"
	        fi
	        $0 status
	        if test $? = 0; then
	                $0 restart
	        else
	                rc_reset        # Not running is not a failure.
	        fi
	        # Remember status and be quiet
	        rc_status
	        ;;
	    reload|force-reload)
	        killproc  -HUP /usr/local/bin/distccd
		rc_status
		;;
	    status)
		echo -n "Checking for Distributed Compiler Daemon: "
		checkproc /usr/local/bin/distccd
		rc_status -v
		;;
	    *)
		echo "Usage: $0
{start|stop|status|restart|try-restart|reload}"
		exit 1
		;;
	esac
	rc_exit

These are both modeled after existing files.  You may remove my name if
you wish.  I'm sure you can clean it up and make it more useful.

(Alternatively, if you already have such files, I would like to see
those.)

Patrick Spiller
Senior Software Engineer
Bally Technologies
6601 South Bermuda Road
Las Vegas, NV 89119
Direct 702.584.7780
Main 702.584.7700
Fax 702.584.7568


-------------- next part --------------
HTML attachment scrubbed and removed


More information about the distcc mailing list