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
%endif

Name:           rancid
Version:        3.9
Release:        0
URL:            http://www.shrubbery.net/rancid/
Summary:        Really Awesome New Cisco confIg Differ
Group:          Productivity/Archiving/Backup
License:        GPL
Source:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.tar.gz
# TODO:
#Source1:        ftp://ftp.shrubbery.net/pub/rancid/contrib/aruba.tgz
#Source2:        ftp://ftp.shrubbery.net/pub/rancid/contrib/pfsense.tgz
Source99:       README.rancid.urpmi
#Patch0:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.p1.gz
#Patch1:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.p2.gz
#Patch2:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.p3.gz
#Patch3:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.p4.gz
#Patch4:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.p5.gz
#Patch5:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.p6.gz
#Patch6:         ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.p7.gz
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

%description
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
      list,
    * 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 http://nitrous.digex.net/, 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. 

%prep
%setup -q
#%%patch0
#%%patch1
#%%patch2
#%%patch3
#%%patch4
#%%patch5
#%%patch6
%patch20
cp %{SOURCE99} README.urpmi

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

%install
mkdir -p %{buildroot}/%{_sysconfdir}/ %{buildroot}/%{_localstatedir}/%{name}
%makeinstall
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 {} \;
EOF

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

%clean
rm -Rf %{buildroot}

%pre
/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 || :

%files
%defattr(-,root,root)
%config(noreplace) %attr(-,root,%{name}) %{_sysconfdir}/
%config(noreplace) %{_sysconfdir}/../cron.d/%{name}
%{_libdir}/%{name}/
%{_datadir}/%{name}/
%dir %attr(750,rancid,rancid) %{_localstatedir}/%{name}
%{_mandir}/man?/*
%doc README README.lg share/README.misc README.urpmi

%changelog