Annotation of /trunk/distcc/distcc-config.sh
Parent Directory | Revision Log
Revision 144 -
(hide annotations)
(download)
(as text)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2367 byte(s)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2367 byte(s)
-import
1 | niro | 144 | #!/bin/bash |
2 | #distcc-config bash | ||
3 | |||
4 | #needed variables | ||
5 | ENVFILE="/etc/env.d/02distcc" | ||
6 | |||
7 | |||
8 | print_usage() | ||
9 | { | ||
10 | echo | ||
11 | echo "Usage: /usr/bin/distcc-config OPTION ARGUMENT" | ||
12 | echo | ||
13 | echo " -s DISTCC_HOSTS sets distcc hosts" | ||
14 | # echo " -l FILENAME sets logfile" | ||
15 | # echo " -v [ 0 | 1 ] sets verbose mode on or off" | ||
16 | echo " -i installs compiler symlinks" | ||
17 | echo " -p prints current config" | ||
18 | echo " -h show this help" | ||
19 | echo | ||
20 | } | ||
21 | |||
22 | #while getopts "s:l:v:pih-" opt | ||
23 | while getopts "s:pih-" opt | ||
24 | do | ||
25 | case "$opt" in | ||
26 | |||
27 | #sets hosts | ||
28 | s) | ||
29 | [ ! -d /etc/distcc ] && install -d /etc/distcc | ||
30 | echo "${OPTARG}" > /etc/distcc/hosts | ||
31 | exit 0 | ||
32 | ;; | ||
33 | |||
34 | # #sets logfile | ||
35 | # l) | ||
36 | # echo ${OPTARG} | ||
37 | # exit 0 | ||
38 | # ;; | ||
39 | # | ||
40 | # #set verbose | ||
41 | # v) | ||
42 | # echo ${OPTARG} | ||
43 | # exit 0 | ||
44 | # ;; | ||
45 | |||
46 | #print config | ||
47 | p) | ||
48 | echo "Configured hosts:" | ||
49 | declare -i x=0 | ||
50 | if [ -n "${DISTCC_HOSTS}" ] | ||
51 | then | ||
52 | echo " Environment:" | ||
53 | for i in ${DISTCC_HOSTS} | ||
54 | do | ||
55 | ((x++)) | ||
56 | echo " ${x}. ${i}" | ||
57 | done | ||
58 | |||
59 | elif [ -f /etc/distcc/hosts ] && | ||
60 | [ "$(stat -c %s /etc/distcc/hosts)" -ne 0 ] | ||
61 | then | ||
62 | echo " /etc/distcc/hosts:" | ||
63 | for i in $(cat /etc/distcc/hosts) | ||
64 | do | ||
65 | ((x++)) | ||
66 | echo " ${x}. ${i}" | ||
67 | done | ||
68 | else | ||
69 | echo " None. Please run distcc-config." | ||
70 | echo " e.g. distcc-config -s \"host1 host2\"" | ||
71 | fi | ||
72 | echo | ||
73 | exit 0 | ||
74 | ;; | ||
75 | |||
76 | #install compiler symlinks | ||
77 | i) | ||
78 | source /etc/mage.rc | ||
79 | for file in gcc cc c++ g++ | ||
80 | do | ||
81 | path="/usr/lib/distcc/bin" | ||
82 | if [ -e "/usr/bin/${file}" ] | ||
83 | then | ||
84 | if [ -n "${CHOST}" ] && | ||
85 | [ "${file}" != "cc" ] && | ||
86 | [ ! -e "${path}/${CHOST}-${file}" ] | ||
87 | then | ||
88 | echo " Creating ${path}/${CHOST}-${file}" | ||
89 | ln -snf /usr/bin/distcc ${path}/${CHOST}-${file} | ||
90 | fi | ||
91 | |||
92 | if [ ! -e "${path}/${file}" ] | ||
93 | then | ||
94 | echo " Creating ${path}/${file}" | ||
95 | ln -snf /usr/bin/distcc ${path}/${file} | ||
96 | fi | ||
97 | fi | ||
98 | done | ||
99 | exit 0 | ||
100 | ;; | ||
101 | |||
102 | #show help | ||
103 | h) | ||
104 | print_usage | ||
105 | exit 0 | ||
106 | ;; | ||
107 | |||
108 | -) | ||
109 | break | ||
110 | ;; | ||
111 | |||
112 | *) | ||
113 | echo "Run '/usr/bin/distcc-config -h' for help." 1>&2 | ||
114 | exit 1 | ||
115 | ;; | ||
116 | esac | ||
117 | done | ||
118 | |||
119 | #next getopt option | ||
120 | shift $(($OPTIND - 1)) | ||
121 | |||
122 | #echo ${USAGE} 1>&2 | ||
123 | echo "Run '/usr/bin/distcc-config -h' for help." 1>&2 | ||
124 | exit 1 |