File rancid.spec of Package rancid

%define _localstatedir /var/lib
%define _bindir %{_libdir}/%{name}/bin
%define _sysconfdir /etc/%{name}

%if %{?mdkversion:0}%{?!mdkversion:1}
%global notmdk 1

Name:           rancid
Version:        3.9
Release:        0
Summary:        Really Awesome New Cisco confIg Differ
Group:          Productivity/Archiving/Backup
License:        GPL
Source99:       README.rancid.urpmi
Patch20:        rancid-2.3.8-dont_override_cflags.patch
Requires:       expect >= 5.40
BuildRequires:  expect >= 5.40
BuildRequires:  iputils
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  postfix
Recommends:     cvs
Recommends:     subversion
Recommends:     cron
PreReq:         pwdutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-root

RANCID monitors a router's (or more generally a device's) configuration,
including software and hardware (cards, serial numbers, etc) and uses CVS
(Concurrent Version System) or Subversion  to maintain history of changes.

RANCID does this by the very simple process summarized here:

    * login to each device in the router table (router.db),
    * run various commands to get the information that will be saved,
    * cook the output; re-format, remove oscillating or incrementing data,
    * email any differences (sample) from the previous collection to a mail
    * and finally commit those changes to the reivision control system

RANCID also includes looking glass software. It is based on Ed Kern's looking
glass which was once used for, for the old-school
folks who remember it. Our version has added functions, supports cisco,
juniper, and foundry and uses the login scripts that come with rancid; so it
can use telnet or ssh to connect to your devices(s).

Rancid currently supports Cisco routers, Juniper routers, Catalyst switches,
Foundry switches, Redback NASs, ADC EZT3 muxes, MRTd (and thus likely IRRd),
Alteon switches, and HP Procurve switches and a host of others.

Rancid is known to be used at: AOL, Global Crossing, MFN, NTT America,
Certainty Solutions Inc. 

%setup -q
cp %{SOURCE99} README.urpmi

export CFLAGS="%{optflags} -D_GNU_SOURCE"
%__make %{?_smp_mflags}

mkdir -p %{buildroot}/%{_sysconfdir}/ %{buildroot}/%{_localstatedir}/%{name}
perl -pi -e 's/^([^#\$])/# $1/g' %{buildroot}/%{_datadir}/%{name}/cloginrc.sample

perl -pi -e 's,^BASEDIR=%{_localstatedir},BASEDIR=%{_localstatedir}/%{name},g;s,/usr/bin\;,%{_sbindir}\;,' %{buildroot}/%{_sysconfdir}/rancid.conf

mkdir -p %{buildroot}/%{_sysconfdir}/../cron.d/
cat << EOF >> %{buildroot}/%{_sysconfdir}/../cron.d/%{name}
# Rancid cron jobs

# Run config differ hourly
1 * * * * rancid %{_libdir}/rancid/rancid-run

# Clean out config differ logs
50 23 * * * rancid /usr/bin/find /var/lib/rancid/logs -type f -mtime +2 -exec rm {} \;

chmod -R u=rwX,g=rX,o= %{buildroot}%{_sysconfdir}

rm -Rf %{buildroot}

/usr/sbin/groupadd -r %{name} &>/dev/null || :
/usr/sbin/useradd -o -g %{name} -s /bin/false -r -c "Rancid" -d %{_localstatedir}/%{name} %{name} &>/dev/null || :

%config(noreplace) %attr(-,root,%{name}) %{_sysconfdir}/
%config(noreplace) %{_sysconfdir}/../cron.d/%{name}
%dir %attr(750,rancid,rancid) %{_localstatedir}/%{name}
%doc README README.lg share/README.misc README.urpmi