/usr/bin/ccontrol-init is in ccontrol 1.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #! /bin/sh
set -e
find()
{
echo -n Looking for $1... >&2
ANS=`which $2 || true`
if [ -z "$ANS" ]; then
if [ $# = 3 ]; then
echo None found\! Giving up. >&2
exit 1
fi
echo "Not found." >&2
elif [ -L "$ANS" ]; then
echo -n "$ANS"... >&2
while [ -L "$ANS" ]; do
LINK=`readlink $ANS`
case $LINK in
/*) ANS=$LINK;;
*) ANS=`dirname $ANS`/$LINK;;
esac
done
echo which is a link to $ANS >&2
else
echo Found "$ANS" >&2
fi
echo `dirname $ANS`
}
test_net()
{
for host; do
echo -n . >&2
if ifconfig | fgrep -q $host; then :;
elif echo | telnet $host distcc 2>&1 | grep -q Connected; then
$GETENT hosts $host | awk '{print $2}'
fi
done
}
ping_network()
{
# There are two kinds of ping (netkit ping and iputils ping)
(ping -w1 -b $1.255 2>/dev/null; ping -c2 $1.255 2>/dev/null) | fgrep "from $1." | sed 's/.*from \([0-9.]*\):.*/\1/' | sort -u
}
scan_for_distcc()
{
local PATH
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
NET=`route -n | grep '^[123456789]' | awk '{print $1}' | head -1`
case "$NET" in
[123456789]*.0)
echo -n scanning network $NET...
set +e
NET=`echo $NET | sed 's/\.0$//'`
HOSTS=`ping_network $NET`
DISTCC_HOSTS=`test_net $HOSTS`
set -e
echo $DISTCC_HOSTS
if [ -z "$DISTCC_HOSTS" ]; then
echo no hosts found, disabling distcc.
return 1
fi
;;
*)
echo no obvious network to scan, disabling distcc.
return 1
;;
esac
return 0
}
# Let's not confuse ourselves: take ~/bin and ccontrol dirs out of path.
PATH=`echo :${PATH}: | sed -e "s,:~/bin:,," -e "s,:$HOME/bin:,," -e "s,:[^:]*ccontrol[^:]*,," | sed -e 's/^://' -e 's/:$//'`
DEST=${1:-$HOME/.ccontrol/default}
CC=`find "C compiler" cc needed`
CPLUSPLUS=`find "C++ compiler" c++ needed`
LD=`find "linker" ld needed`
MAKE=`find "make" make needed`
DISTCC=`find "distcc" distcc`
CCACHE=`find "ccache" ccache`
GETENT=`which getent || echo echo`
echo -n Counting CPUs on this machine...
PROCESSORS=`grep -cw ^processor < /proc/cpuinfo` 2>/dev/null
if [ "$PROCESSORS" -gt 0 ] 2> /dev/null; then
echo found $PROCESSORS
else
echo too hard, assuming 1
PROCESSORS=1
fi
if [ -n "$DISTCC" ]; then
echo -n Looking for distcc hosts...
if [ -n "$DISTCC_HOSTS" ]; then
echo $DISTCC_HOSTS
else
if scan_for_distcc; then :; else
DISTCC=""
fi
fi
fi
if [ "$DEST" = $HOME/.ccontrol/default ]; then
if [ -f $HOME/.ccontrol ]; then
echo Found old .ccontrol file, moving to .ccontrol.old
mv -i $HOME/.ccontrol $HOME/.ccontrol.old
if [ -f $HOME/.ccontrol ]; then
echo Aborting.
exit 1
fi
fi
fi
DIRNAME=`dirname "$DEST"`
if [ ! -d "$DIRNAME" ]; then
echo Creating $DIRNAME directory
mkdir -p "$DIRNAME"
elif [ -L "$DEST" ]; then
rm $DEST
elif [ -f "$DEST" ]; then
echo Moving existing "$DEST" to "$DEST".old
mv -i "$DEST" "$DEST".old
if [ -f $DEST ]; then
echo Aborting.
exit 1
fi
fi
echo '[*]' > "$DEST"
echo " cc = $CC" >> "$DEST"
echo " c++ = $CPLUSPLUS" >> "$DEST"
echo " ld = $LD" >> "$DEST"
echo " make = $MAKE" >> "$DEST"
if [ $PROCESSORS -gt 1 ]; then
echo " cpus = $PROCESSORS" >> "$DEST"
fi
if [ -n "$DISTCC" ]; then
echo " distcc = $DISTCC" >> "$DEST"
echo " distcc-hosts = `echo $DISTCC_HOSTS`" >> "$DEST"
fi
if [ -n "$CCACHE" ]; then
echo " ccache = $CCACHE" >> "$DEST"
fi
echo
echo Created "$DEST"
if [ "$DEST" = $HOME/.ccontrol/default ]; then
ln -s $DEST ~/.ccontrol/config
echo Created symlink ~/.ccontrol/config
fi
|