# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI=3 inherit eutils autotools DESCRIPTION="RANCID - Really Awesome New Cisco confIg Differ" HOMEPAGE="http://www.shrubbery.net/rancid/" SRC_URI="ftp://ftp.shrubbery.net/pub/rancid/${P}.tar.gz" SLOT="0" RESTRICT="mirror" KEYWORDS="amd64 x86" IUSE="svn cvs" DEPEND=" sys-apps/diffutils dev-lang/perl dev-tcltk/expect dev-lang/tcl svn? ( dev-vcs/subversion ) cvs? ( dev-vcs/cvs ) || ( net-misc/netkit-telnetd net-misc/telnet-bsd ) " RANCID_DIR=/var/rancid src_configure() { if use svn ; then econf \ --localstatedir=${RANCID_DIR} / \ --enable-conf-install --with-svn=fsfs || die "econf failed" else econf \ --localstatedir=${RANCID_DIR} \ --enable-conf-install || die "econf failed" fi } src_compile() { emake || die "emake failed" } src_install() { emake DESTDIR=${D} install || die "make install failed" } pkg_preinst() { ebegin "Creating rancid user and group" enewgroup ${PN} enewuser ${PN} -1 /bin/bash ${RANCID_DIR} ${PN} -c "Rancid" keepdir ${RANCID_DIR} keepdir ${RANCID_DIR}/logs mkdir ${D}/${RANCID_DIR}/example touch ${D}/${RANCID_DIR}/example/routers.db touch ${D}/${RANCID_DIR}/.cloginrc fperms 0770 ${RANCID_DIR} fperms 0770 ${RANCID_DIR}/logs fperms 0770 ${RANCID_DIR}/example fperms 0660 ${RANCID_DIR}/example/routers.db fperms 0660 ${RANCID_DIR}/.cloginrc fowners rancid:rancid ${RANCID_DIR} fowners rancid:rancid ${RANCID_DIR}/logs fowners rancid:rancid ${RANCID_DIR}/example fowners rancid:rancid ${RANCID_DIR}/example/routers.db fowners rancid:rancid ${RANCID_DIR}/.cloginrc } pkg_postinst() { if use svn ; then cd ${ROOT} patch -p0 -s < ${FILESDIR}/control_rancid.patch sed -ie 's/^RCSSYS=cvs/RCSSYS=svn/' ${ROOT}/etc/rancid.conf fi einfo "Micro-HOWTO on how to get running:" einfo "" einfo "1) Schedule regular backups with rancid-run:" einfo "Edit user rancid crontab crontab -u rancid -e and add the lines below" einfo "# rancid-run one time a day" einfo "0 0 * * * /usr/bin/rancid-run" einfo "50 23 * * * /usr/bin/find /var/rancid/logs -type f -mtime +2 -exec rm {} \;" einfo "" einfo "2: Modify LIST_OF_GROUPS in /etc/rancid.conf:" einfo "LIST_OF_GROUPS=\"routers switches\"" einfo "" einfo "3: Modify /etc/mail/aliases and set up directories for rancid," einfo "a quick oneliner for bash for the two grops above:" einfo "for n in routers switches; do" einfo " mkdir /var/rancid/\$n; chown rancid:rancid /var/rancid/\$n;" einfo " touch /var/rancid/\$n/routers.db" einfo " echo -e \"rancid-\$n: noc@acme.com" >> /etc/mail/aliases\" einfo " echo -e \"rancid-admin-\$n: noc@acme.com" >> /etc/mail/aliases\" einfo "done; newalises" einfo "" einfo "4) Run rancid-cvs to initialise directories and repositories" einfo "" einfo "5) Populate /var/rancid/*/routers.db with nodes (look in example dir)" einfo "" einfo "6) Populate /var/rancid/.cloginrc with credentials" einfo "" einfo "7) Test with: clogin 1.2.3.4" einfo "" einfo "FAQ: why does clogin hang? Your login banner has # or > in it, use = instead" einfo "" }