#!/bin/bash
export DISTCC_JOBS=$(distcc -j)
echo " * Testing distcc..."
# test distcc .. distcc won't distribute stdin so make temp file
Z_HELLO_C='I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIHByaW50ZigiSGVsbG8gZGlzdGNjIVxuIik7CiAgICByZXR1cm4gMDsKfQo='
DISTCC_VERBOSE=1
Z_TMP=$(mktemp --suffix='.c')
echo "${Z_HELLO_C}" | base64 -d > "${Z_TMP}"
Z_TEST=$(distcc "$(realpath "$(which gcc)")" -o /dev/null -c "${Z_TMP}" 2>&1)
rm "${Z_TMP}"
Z_RES=$(echo "${Z_TEST}" | grep -c 'failed to distribute')
unset DISTCC_VERBOSE
if [ ${Z_RES} -gt 0 ]; then
echo " ! Your distcc host is not working! Please fix or try again with distcc mode"
echo "${Z_TEST}"
exit 1;
else
echo " * Okay! :)"
fi
Comments