#!/bin/sh
# Start/stop/restart distccd

##############################################################################
# DISTCCD CONFIG OPTIONS - EDIT TO MATCH YOUR CONFIG!
# Set the --listen and --allow parameters appropriately for your
# configuration. The default settings are just examples which are useful
# in practice only if you plan to use distcc over SSH connections. See
# distccd(1) man page for detailed documentation of all distccd options.

DISTCCD_CONFIG="--listen 127.0.0.1 --allow 127.0.0.0/8"

##############################################################################


# These settings should be OK in most cases and don't need to be changed
# unless you want to run distccd under different user than 'nobody':
DISTCCD_ARGS="--daemon -N20 --user nobody"


distccd_start() {
  # If distccd is already running, it won't start more copies unless
  # binding to a different port.
  echo "Starting distccd:  /usr/bin/distccd $DISTCCD_ARGS $DISTCCD_CONFIG"
  /usr/bin/distccd $DISTCCD_ARGS $DISTCCD_CONFIG
}	

distccd_stop() {
  killall distccd
}	

distccd_restart() {
  distccd_stop
  sleep 2
  distccd_start
}  

case "$1" in
  start)   distccd_start ;;
  stop)    distccd_stop ;;
  restart) distccd_restart ;;
  *)       echo "usage $0 start|stop|restart" ;;
esac
