dev-python/python-axolotl-curve25519: New package
[gentoo.git] / net-misc / rancid / rancid-2.3.8.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit autotools eutils readme.gentoo user
7
8 DESCRIPTION="Really Awesome New Cisco confIg Differ"
9 HOMEPAGE="http://www.shrubbery.net/rancid/"
10 SRC_URI="http://http.debian.net/debian/pool/main/${PN:0:1}/${PN}/${PN}_${PV}.orig.tar.gz -> ${P}.tar.gz"
11 LICENSE="BSD-4"
12
13 SLOT="0"
14 RESTRICT="mirror"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="+cvs subversion"
17
18 REQUIRED_USE="^^ ( cvs subversion )"
19
20 # app-arch/par is blocker, due to bug #455838
21 DEPEND="
22         !app-arch/par
23         dev-lang/perl
24         dev-lang/tcl:0=
25         dev-tcltk/expect
26         sys-apps/diffutils
27         cvs? ( dev-vcs/cvs )
28         subversion? ( dev-vcs/subversion )
29         || (
30                 net-misc/netkit-telnetd
31                 net-misc/telnet-bsd
32         )"
33 RDEPEND="${DEPEND}"
34
35 src_prepare() {
36         epatch "${FILESDIR}"/${P}-mailprefix.patch
37         epatch "${FILESDIR}"/${P}-config.patch
38         epatch "${FILESDIR}"/${P}-buildsystem.patch
39
40         # respect CFLAGS, bug #455840
41         sed -i -e '/^CFLAGS/d' bin/Makefile.am || die 'sed on bin/Makefile.am failed'
42
43         eautoreconf
44 }
45
46 src_configure() {
47         econf \
48                 --localstatedir="${EPREFIX}"/var/${PN} \
49                 --enable-conf-install \
50                 --docdir="${EPREFIX}"/usr/share/doc/${PF} \
51                 --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html \
52                 $(use subversion && echo "--with-svn=fsfs")
53 }
54
55 src_install() {
56         default
57
58         if use subversion ; then
59                 sed -e 's/^RCSSYS=cvs/RCSSYS=svn/' \
60                         -i "${D}"/etc/rancid.conf || die
61         fi
62
63         echo "CONFIG_PROTECT=\"${EPREFIX}/var/rancid/.cloginrc\"" > "${T}"/99${PN}
64         doenvd "${T}"/99${PN}
65
66         readme.gentoo_src_install
67 }
68
69 pkg_preinst() {
70         enewgroup ${PN}
71         enewuser ${PN} -1 /bin/bash "${EPREFIX}"/var/rancid ${PN}
72
73         keepdir /var/${PN}{,/logs}
74         touch   "${ED}"/var/${PN}/.cloginrc
75
76         fperms ug=rwX,o= /var/${PN}/{,logs,.cloginrc}
77         fowners ${PN}:${PN} /var/${PN}/{,logs,.cloginrc}
78 }
79
80 DISABLE_AUTOFORMATTING="yes"
81 DOC_CONTENTS="Micro-HOWTO on how to get running:
82
83 1) Modify MAILPREFIX, ADMINMAILPREFIX, and LIST_OF_GROUPS
84 in /etc/rancid.conf:
85 MAILPREFIX=\"rancid-\"
86 ADMINMAILPREFIX=\"rancid-admin-\"
87 LIST_OF_GROUPS=\"routers switches\"
88
89 2) Setup email aliases for rancid:
90 you will need to define mail aliases for {MAILPREFIX}{GROUP}
91 and {ADMINMAILPREFIX}{GROUP} for each group you defined above
92 How to do this depends on your mailserver
93
94 3) Run rancid-cvs as the rancid user to initialise directories and
95 repositories; eg. su -c /usr/bin/rancid-cvs - rancid
96 Note the command is the same even if you are using subversion
97
98 4) Populate /var/rancid/{GROUPNAME}/router.db with nodes
99 see man 5 router.db for detailed formatting information
100
101 5) Populate /var/rancid/.cloginrc with credentials
102 see /usr/share/rancid/cloginrc.sample for an example
103
104 6) Test clogin access with: clogin -f /var/rancid/.clogin hostname
105
106 7) Add a cronjob for the rancid user to regularly call rancid-run
107 eg: run crontab -u rancid -e and add the lines below
108 # run rancid once an hour
109 0 * * * *       /usr/bin/rancid-run
110 # cleanup old logfiles generated by rancid once a day
111 50 23 * * *     /usr/bin/find /var/rancid/logs -type f -mtime +2 -exec rm {} \;
112 "