view 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
line wrap: on
line source

#! /bin/sh -e

# correct map file when switching between DCC and DCC Reputation code.

# Copyright (c) 2008 by Rhyolite Software, LLC
#
# This agreement is not applicable to any entity which sells anti-spam
# solutions to others or provides an anti-spam solution as part of a
# security solution sold to other entities, or to a private network
# which employs the DCC or uses data provided by operation of the DCC
# but does not provide corresponding data to other users.
#
# Permission to use, copy, modify, and distribute this software without
# changes for any purpose with or without fee is hereby granted, provided
# that the above copyright notice and this permission notice appear in all
# copies and any distributed versions or copies are either unchanged
# or not called anything similar to "DCC" or "Distributed Checksum
# Clearinghouse".
#
# Parties not eligible to receive a license under this agreement can
# obtain a commercial license to use DCC by contacting Rhyolite Software
# at sales@rhyolite.com.
#
# A commercial license would be for Distributed Checksum and Reputation
# Clearinghouse software.  That software includes additional features.  This
# free license for Distributed ChecksumClearinghouse Software does not in any
# way grant permision to use Distributed Checksum and Reputation Clearinghouse
# software
#
# THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC
# BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.

#	Rhyolite Software DCC 1.3.103-1.11 $Revision$


set -e

SUFFIX=`date +%y%m%d`
DCC_HOMEDIR=
CDCC=
MAP=map

USAGE="$0: [-x] [-m map] -c cdcc -h homedir"
while getopts "xm:c:h:" c; do
    case $c in
	x) set -x;;
	m) MAP="$OPTARG";;
	c) CDCC="$OPTARG";;
	h) DCC_HOMEDIR="$OPTARG";;
	*) echo "$USAGE" 1>&2; exit 1;;
    esac
done
shift `expr $OPTIND - 1 || true`
if test "$#" -ne 0 -o -z "$CDCC" -o -z "$DCC_HOMEDIR"			\
	    -o ! -d "$DCC_HOMEDIR/."; then
    echo "$USAGE" 1>&2
    exit 1
fi
if expr "$MAP" : '/.*' >/dev/null; then :
else
    MAP=$DCC_HOMEDIR/$MAP
fi
if test ! -f "$MAP"; then
    echo "$MAP does not exist" 1>&2
    exit 1
fi
if test ! -w "$MAP" -o ! -r "$MAP"; then
    echo "$MAP not readable and writable" 1>&2
    exit 1
fi

if test ! -x "$CDCC"; then
    # the cdcc command has usually not yet been installed, so use the local
    #	version
    echo "$CDCC does not seem to have been built" 1>&2
    exit 1
fi
CDCC_CMD="$CDCC -qh $DCC_HOMEDIR file=$MAP"
$CDCC_CMD >/dev/null </dev/null			# see that it works

RSRVR=com-dcc.rhyolite.com
RID=
RPASSWD=
if test -r $DCC_HOMEDIR/.updatedcc_pfile				\
	    -a -s $DCC_HOMEDIR/.updatedcc_pfile; then
    . $DCC_HOMEDIR/.updatedcc_pfile
fi
if test -r .updatedcc_pfile -a -s .updatedcc_pfile; then
    . ./.updatedcc_pfile
fi

USING_DCC=`$CDCC_CMD info						\
    | sed -n -e 's/^\([-a-z0-9]*\.dcc-servers\.net\),.*/\1/p'`
USING_RHYOLITE=`$CDCC_CMD info						\
    | sed -n -e 's/^\([-a-z0-9]*\.rhyolite\.com\),.*/\1/p'`


# Replace references to the common DCC Reputation servers when installing the
#   free DCC client software because the common DCC Reputation servers have
#   probably forgotten this client's ID and so will refuse to answer.
#   When we remove the common DCC Reputation servers, add the public servers
#   as low priority backups to avoid leaving things broken.
if test -n "$USING_RHYOLITE"; then
    $CDCC_CMD "add dcc1.dcc-servers.net RTT+2000 ms"			\
	"add dcc2.dcc-servers.net RTT+2000 ms"				\
	"add dcc3.dcc-servers.net RTT+2000 ms"				\
	"add dcc4.dcc-servers.net RTT+2000 ms"				\
	"add dcc5.dcc-servers.net RTT+2000 ms"
    for s in $USING_RHYOLITE; do
	$CDCC_CMD "delete $s"
    done
fi