Annotation of /trunk/distcc/distcc-config.sh
Parent Directory | Revision Log
Revision 943 -
(hide annotations)
(download)
(as text)
Tue Dec 1 10:41:10 2009 UTC (14 years, 11 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, 11 months ago) by niro
File MIME type: application/x-sh
File size: 2488 byte(s)
-modernize
1 | niro | 144 | #!/bin/bash |
2 | niro | 943 | # distcc-config bash |
3 | niro | 144 | |
4 | niro | 943 | # needed variables |
5 | niro | 144 | 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 | niro | 943 | # sets hosts |
27 | niro | 144 | s) |
28 | [ ! -d /etc/distcc ] && install -d /etc/distcc | ||
29 | echo "${OPTARG}" > /etc/distcc/hosts | ||
30 | exit 0 | ||
31 | ;; | ||
32 | |||
33 | niro | 943 | # # sets logfile |
34 | niro | 144 | # l) |
35 | # echo ${OPTARG} | ||
36 | # exit 0 | ||
37 | # ;; | ||
38 | # | ||
39 | niro | 943 | # # set verbose |
40 | niro | 144 | # v) |
41 | # echo ${OPTARG} | ||
42 | # exit 0 | ||
43 | # ;; | ||
44 | |||
45 | niro | 943 | # print config |
46 | niro | 144 | 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 | niro | 943 | (cat /etc/distcc/hosts; echo) | # make sure there is a LF at the end |
63 | while read line | ||
64 | niro | 144 | do |
65 | niro | 943 | case "${line}" in |
66 | \#*|"") continue ;; | ||
67 | esac | ||
68 | niro | 144 | ((x++)) |
69 | niro | 943 | echo " ${x}. ${line}" |
70 | done < /etc/distcc/hosts | ||
71 | niro | 144 | 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 | niro | 943 | |
79 | # install compiler symlinks | ||
80 | niro | 144 | 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 | niro | 943 | |
105 | niro | 144 | #show help |
106 | h) | ||
107 | print_usage | ||
108 | exit 0 | ||
109 | ;; | ||
110 | niro | 943 | |
111 | -) | ||
112 | niro | 144 | break |
113 | ;; | ||
114 | |||
115 | niro | 943 | *) |
116 | niro | 144 | 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 |