Mercurial > notdcc
comparison homedir/make-dcc_conf @ 0:c7f6b056b673
First import of vendor version
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Tue, 10 Mar 2009 13:49:58 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c7f6b056b673 |
---|---|
1 #! /bin/sh -e | |
2 | |
3 # generate a new dcc_conf file from an existing file | |
4 | |
5 # Copyright (c) 2008 by Rhyolite Software, LLC | |
6 # | |
7 # This agreement is not applicable to any entity which sells anti-spam | |
8 # solutions to others or provides an anti-spam solution as part of a | |
9 # security solution sold to other entities, or to a private network | |
10 # which employs the DCC or uses data provided by operation of the DCC | |
11 # but does not provide corresponding data to other users. | |
12 # | |
13 # Permission to use, copy, modify, and distribute this software without | |
14 # changes for any purpose with or without fee is hereby granted, provided | |
15 # that the above copyright notice and this permission notice appear in all | |
16 # copies and any distributed versions or copies are either unchanged | |
17 # or not called anything similar to "DCC" or "Distributed Checksum | |
18 # Clearinghouse". | |
19 # | |
20 # Parties not eligible to receive a license under this agreement can | |
21 # obtain a commercial license to use DCC by contacting Rhyolite Software | |
22 # at sales@rhyolite.com. | |
23 # | |
24 # A commercial license would be for Distributed Checksum and Reputation | |
25 # Clearinghouse software. That software includes additional features. This | |
26 # free license for Distributed ChecksumClearinghouse Software does not in any | |
27 # way grant permision to use Distributed Checksum and Reputation Clearinghouse | |
28 # software | |
29 # | |
30 # THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL | |
31 # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | |
32 # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC | |
33 # BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES | |
34 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
35 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
36 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
37 # SOFTWARE. | |
38 | |
39 # Rhyolite Software DCC 1.3.103-1.23 $Revision$ | |
40 | |
41 FNAME=dcc_conf | |
42 | |
43 CUR= | |
44 PROTOTYPE=$FNAME | |
45 SUFFIX=new | |
46 NEW= | |
47 DCC_HOMEDIR= | |
48 | |
49 USAGE="$0: [-x] [-i cur] [-s new-suffix] [-p prototype] [-o new] -h homedir" | |
50 while getopts "xi:s:p:o:h:" c; do | |
51 case $c in | |
52 x) set -x;; | |
53 i) CUR="$OPTARG";; | |
54 s) if test -n "$OPTARG"; then | |
55 SUFFIX="$OPTARG" | |
56 fi | |
57 ;; | |
58 p) PROTOTYPE="$OPTARG";; | |
59 o) NEW="$OPTARG";; | |
60 h) DCC_HOMEDIR="$OPTARG";; | |
61 *) echo "$USAGE" 1>&2; exit 1;; | |
62 esac | |
63 done | |
64 shift `expr $OPTIND - 1 || true` | |
65 if test "$#" -ne 0 -o ! -d "$DCC_HOMEDIR"; then | |
66 echo "$USAGE" 1>&2 | |
67 exit 1 | |
68 fi | |
69 | |
70 if test ! -s "$PROTOTYPE"; then | |
71 echo "prototype $PROTOTYPE does not exist" 1>&2 | |
72 exit 1 | |
73 fi | |
74 | |
75 if test -z "$CUR"; then | |
76 CUR="$DCC_HOMEDIR/$FNAME" | |
77 fi | |
78 if test ! -f "$CUR"; then | |
79 echo "$CUR does not exist" 1>&2 | |
80 exit 1 | |
81 fi | |
82 | |
83 if test -z "$NEW"; then | |
84 NEW="$CUR-$SUFFIX" | |
85 fi | |
86 | |
87 # Use /^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/ patterns instead of easier to read, | |
88 # probably faster /^[A-Z/ patterns because someone has decided that | |
89 # GNU Awk 3.1.3 (at least on x86_64) should have /^[A-Z]/ match "fi" | |
90 # with IGNORECASE=0 and even in traditional mode. | |
91 | |
92 rm -f $NEW | |
93 awk '(first_file == "") { | |
94 first_file = FILENAME; | |
95 } | |
96 /^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/ { | |
97 # deal with continuation lines | |
98 line = $0; | |
99 while (substr(line,length(line)) == "\\") { | |
100 if (getline <= 0) { | |
101 break; | |
102 } | |
103 line = line "\n" $0; | |
104 } | |
105 # divide the line into the variable name or key and its value | |
106 inx = index(line, "="); | |
107 if (inx == 0) { | |
108 inx = length(line)+1; | |
109 } | |
110 key = substr(line, 1, inx-1); | |
111 val = substr(line, inx+1); | |
112 # only record things in the first file | |
113 if (first_file == FILENAME) { | |
114 defined[key] = 1; | |
115 mem[key] = val; | |
116 if (cur_comment) { | |
117 comments[key] = cur_comment; | |
118 cur_comment = ""; | |
119 } | |
120 } else { | |
121 # on first line of second file, make compatibility adjustments | |
122 if (!adjusted) { | |
123 adjusted = 1; | |
124 if (mem["DCCD_ENABLE"] == "") { | |
125 defined["DCCD_ENABLE"] = 1; | |
126 if (mem["SRVR_ID"] == "") { | |
127 mem["DCCD_ENABLE"] = "off"; | |
128 } else { | |
129 mem["DCCD_ENABLE"] = "on"; | |
130 } | |
131 } | |
132 # fix DCC_RUNDIR=@dcc_rundir@ bug in 1.2.14 and preceding | |
133 if (defined["DCC_RUNDIR"]) { | |
134 if (mem["DCC_RUNDIR"] == "@dcc_rundir@") { | |
135 defined["DCC_RUNDIR"] = 0; | |
136 } | |
137 } | |
138 # Use new values of some variables if their old values were | |
139 # defaults. This makes ./configure changes effective. | |
140 if (mem["Configure_DCC_LIBEXEC"] == mem["DCC_LIBEXEC"]) { | |
141 defined["DCC_LIBEXEC"] = 0; | |
142 } | |
143 if (mem["Configure_DCC_RUNDIR"] == mem["DCC_RUNDIR"]) { | |
144 defined["DCC_RUNDIR"] = 0; | |
145 } | |
146 if (mem["Configure_DCCSUID"] == mem["DCCSUID"]) { | |
147 defined["DCCSUID"] = 0; | |
148 } | |
149 if (mem["Configure_DCC_LOGGER"] == mem["DCC_LOGGER"]) { | |
150 defined["DCC_LOGGER"] = 0; | |
151 } | |
152 # use new, configured values of some variables | |
153 if (defined["DCC_CONF_VERSION"]) | |
154 old_version = mem["DCC_CONF_VERSION"]; | |
155 defined["DCC_CONF_VERSION"] = 0; | |
156 defined["Configure_DCC_LIBEXEC"] = 0; | |
157 defined["Configure_DCC_RUNDIR"] = 0; | |
158 defined["Configure_DCCSUID"] = 0; | |
159 defined["Configure_DCC_LOGGER"] = 0; | |
160 } | |
161 if (defined[key]) { | |
162 if (comments[key] && old_version > 3) { | |
163 print comments[key]; | |
164 } | |
165 print key "=" mem[key]; | |
166 } else { | |
167 print line; | |
168 } | |
169 } | |
170 } | |
171 !/^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/ { | |
172 if (FILENAME != first_file) { | |
173 print $0; | |
174 } else { | |
175 if ($0 ~ /^ *#/ && $1 != "#") { | |
176 if (cur_comment) { | |
177 cur_comment = cur_comment "\n" $0; | |
178 } else { | |
179 cur_comment = $0; | |
180 } | |
181 } | |
182 } | |
183 }' $CUR $PROTOTYPE >$NEW |