#!/bin/bash #distcc-config bash #needed variables ENVFILE="/etc/env.d/02distcc" print_usage() { echo echo "Usage: /usr/bin/distcc-config OPTION ARGUMENT" echo echo " -s DISTCC_HOSTS sets distcc hosts" # echo " -l FILENAME sets logfile" # echo " -v [ 0 | 1 ] sets verbose mode on or off" echo " -i installs compiler symlinks" echo " -p prints current config" echo " -h show this help" echo } #while getopts "s:l:v:pih-" opt while getopts "s:pih-" opt do case "$opt" in #sets hosts s) [ ! -d /etc/distcc ] && install -d /etc/distcc echo "${OPTARG}" > /etc/distcc/hosts exit 0 ;; # #sets logfile # l) # echo ${OPTARG} # exit 0 # ;; # # #set verbose # v) # echo ${OPTARG} # exit 0 # ;; #print config p) echo "Configured hosts:" declare -i x=0 if [ -n "${DISTCC_HOSTS}" ] then echo " Environment:" for i in ${DISTCC_HOSTS} do ((x++)) echo " ${x}. ${i}" done elif [ -f /etc/distcc/hosts ] && [ "$(stat -c %s /etc/distcc/hosts)" -ne 0 ] then echo " /etc/distcc/hosts:" for i in $(cat /etc/distcc/hosts) do ((x++)) echo " ${x}. ${i}" done else echo " None. Please run distcc-config." echo " e.g. distcc-config -s \"host1 host2\"" fi echo exit 0 ;; #install compiler symlinks i) source /etc/mage.rc for file in gcc cc c++ g++ do path="/usr/lib/distcc/bin" if [ -e "/usr/bin/${file}" ] then if [ -n "${CHOST}" ] && [ "${file}" != "cc" ] && [ ! -e "${path}/${CHOST}-${file}" ] then echo " Creating ${path}/${CHOST}-${file}" ln -snf /usr/bin/distcc ${path}/${CHOST}-${file} fi if [ ! -e "${path}/${file}" ] then echo " Creating ${path}/${file}" ln -snf /usr/bin/distcc ${path}/${file} fi fi done exit 0 ;; #show help h) print_usage exit 0 ;; -) break ;; *) echo "Run '/usr/bin/distcc-config -h' for help." 1>&2 exit 1 ;; esac done #next getopt option shift $(($OPTIND - 1)) #echo ${USAGE} 1>&2 echo "Run '/usr/bin/distcc-config -h' for help." 1>&2 exit 1