Mercurial > notdcc
comparison homedir/fix-map @ 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 # correct map file when switching between DCC and DCC Reputation code. | |
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.11 $Revision$ | |
40 | |
41 | |
42 set -e | |
43 | |
44 SUFFIX=`date +%y%m%d` | |
45 DCC_HOMEDIR= | |
46 CDCC= | |
47 MAP=map | |
48 | |
49 USAGE="$0: [-x] [-m map] -c cdcc -h homedir" | |
50 while getopts "xm:c:h:" c; do | |
51 case $c in | |
52 x) set -x;; | |
53 m) MAP="$OPTARG";; | |
54 c) CDCC="$OPTARG";; | |
55 h) DCC_HOMEDIR="$OPTARG";; | |
56 *) echo "$USAGE" 1>&2; exit 1;; | |
57 esac | |
58 done | |
59 shift `expr $OPTIND - 1 || true` | |
60 if test "$#" -ne 0 -o -z "$CDCC" -o -z "$DCC_HOMEDIR" \ | |
61 -o ! -d "$DCC_HOMEDIR/."; then | |
62 echo "$USAGE" 1>&2 | |
63 exit 1 | |
64 fi | |
65 if expr "$MAP" : '/.*' >/dev/null; then : | |
66 else | |
67 MAP=$DCC_HOMEDIR/$MAP | |
68 fi | |
69 if test ! -f "$MAP"; then | |
70 echo "$MAP does not exist" 1>&2 | |
71 exit 1 | |
72 fi | |
73 if test ! -w "$MAP" -o ! -r "$MAP"; then | |
74 echo "$MAP not readable and writable" 1>&2 | |
75 exit 1 | |
76 fi | |
77 | |
78 if test ! -x "$CDCC"; then | |
79 # the cdcc command has usually not yet been installed, so use the local | |
80 # version | |
81 echo "$CDCC does not seem to have been built" 1>&2 | |
82 exit 1 | |
83 fi | |
84 CDCC_CMD="$CDCC -qh $DCC_HOMEDIR file=$MAP" | |
85 $CDCC_CMD >/dev/null </dev/null # see that it works | |
86 | |
87 RSRVR=com-dcc.rhyolite.com | |
88 RID= | |
89 RPASSWD= | |
90 if test -r $DCC_HOMEDIR/.updatedcc_pfile \ | |
91 -a -s $DCC_HOMEDIR/.updatedcc_pfile; then | |
92 . $DCC_HOMEDIR/.updatedcc_pfile | |
93 fi | |
94 if test -r .updatedcc_pfile -a -s .updatedcc_pfile; then | |
95 . ./.updatedcc_pfile | |
96 fi | |
97 | |
98 USING_DCC=`$CDCC_CMD info \ | |
99 | sed -n -e 's/^\([-a-z0-9]*\.dcc-servers\.net\),.*/\1/p'` | |
100 USING_RHYOLITE=`$CDCC_CMD info \ | |
101 | sed -n -e 's/^\([-a-z0-9]*\.rhyolite\.com\),.*/\1/p'` | |
102 | |
103 | |
104 # Replace references to the common DCC Reputation servers when installing the | |
105 # free DCC client software because the common DCC Reputation servers have | |
106 # probably forgotten this client's ID and so will refuse to answer. | |
107 # When we remove the common DCC Reputation servers, add the public servers | |
108 # as low priority backups to avoid leaving things broken. | |
109 if test -n "$USING_RHYOLITE"; then | |
110 $CDCC_CMD "add dcc1.dcc-servers.net RTT+2000 ms" \ | |
111 "add dcc2.dcc-servers.net RTT+2000 ms" \ | |
112 "add dcc3.dcc-servers.net RTT+2000 ms" \ | |
113 "add dcc4.dcc-servers.net RTT+2000 ms" \ | |
114 "add dcc5.dcc-servers.net RTT+2000 ms" | |
115 for s in $USING_RHYOLITE; do | |
116 $CDCC_CMD "delete $s" | |
117 done | |
118 fi |