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