#!/bin/sh
exec 2>&1
PROG="distccd"
USER="nobody"
OPTIONS="--no-detach"
OPTIONS="$OPTIONS --daemon"
OPTIONS="$OPTIONS --user $USER"
ALLOW_FILE=/etc/distcc/clients.allow
if [ -f "$ALLOW_FILE" ]; then
        ALLOW_OPTIONS=$(sed -e 's/#.*$//' -e '/^\s*$/d' -e 's/^/--allow /' < $ALLOW_FILE)
fi
if [ -z "$ALLOW_OPTIONS" ]; then
        # Default to allow localhost
        ALLOW_OPTIONS="--allow 127.0.0.1"
fi
OPTIONS="$OPTIONS $ALLOW_OPTIONS"
exec $PROG $OPTIONS
