1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
8 DESCRIPTION="Proxy DNS server with permanent caching"
9 HOMEPAGE="http://members.home.nl/p.a.rombouts/pdnsd/"
10 SRC_URI="http://members.home.nl/p.a.rombouts/pdnsd/releases/${P}-par.tar.gz"
14 KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~s390 ~sparc ~x86"
15 IUSE="debug ipv6 isdn +urandom test"
16 RESTRICT="!test? ( test )"
22 DEPEND="test? ( net-dns/bind-tools )"
26 --sysconfdir="${EPREFIX}"/etc/pdnsd
27 --with-cachedir="${EPREFIX}"/var/cache/pdnsd
28 --with-default-id=pdnsd
30 $(use_enable ipv6 ipv6-startup)
32 $(usex debug '--with-debug=3' '')
33 $(usex urandom "--with-random-device=${EPREFIX}/dev/urandom" '')
36 econf "${myeconfargs[@]}"
40 local DOCS=( AUTHORS ChangeLog* NEWS README THANKS TODO README.par )
44 dodoc contrib/{README,dhcp2pdnsd,pdnsd_dhcp.pl}
50 newdoc doc/pdnsd.conf pdnsd.conf.sample
52 newinitd "${FILESDIR}/pdnsd.rc8" pdnsd
53 newconfd "${FILESDIR}/pdnsd.confd" pdnsd
54 newinitd "${FILESDIR}/pdnsd.online.2" pdnsd-online
55 newconfd "${FILESDIR}/pdnsd-online.confd" pdnsd-online
56 systemd_newtmpfilesd "${FILESDIR}/pdnsd.tmpfiles" pdnsd.conf
57 systemd_dounit "${FILESDIR}/pdnsd.service"
62 kill -9 $(<"${T}"/pid)
66 mkdir "${T}/pdnsd" || die
67 echo -n -e "pd12\0\0\0\0" > "${T}/pdnsd/pdnsd.cache"
68 IPS="$(grep ^nameserver /etc/resolv.conf | sed -e 's/nameserver \(.*\)/\tip=\1;/g' | xargs)"
69 sed -e "s/\tip=/${IPS}/" -e "s:cache_dir=:cache_dir=${T}/pdnsd:" "${FILESDIR}/pdnsd.conf.test" \
70 > "${T}/pdnsd.conf.test"
71 src/pdnsd -c "${T}/pdnsd.conf.test" -g -s -d -p "${T}/pid" || die "couldn't start daemon"
75 [ -s "${T}/pid" ] || die "empty or no pid file created"
76 [ -S "${T}/pdnsd/pdnsd.status" ] || fail_kill "no socket created"
77 src/pdnsd-ctl/pdnsd-ctl -c "${T}/pdnsd" server all up || fail_kill "failed to start the daemon"
78 src/pdnsd-ctl/pdnsd-ctl -c "${T}/pdnsd" status || fail_kill "failed to communicate with the daemon"
81 dig @127.0.0.1 -p 33455 localhost > "${T}"/dig.output 2>&1
82 cat "${T}"/dig.output || die
83 fgrep -q "status: NOERROR" "${T}"/dig.output || fail_kill "www.gentoo.org lookup failed"
85 kill $(<"${T}/pid") || fail_kill "failed to terminate daemon"
90 elog "Add pdnsd to your default runlevel - rc-update add pdnsd default"
92 elog "Add pdnsd-online to your online runlevel."
93 elog "The online interface will be listed in /etc/conf.d/pdnsd-online"
95 elog "Sample config file in /etc/pdnsd/pdnsd.conf.sample"
97 # The tmpfiles.d configuration does not come into effect before the
98 # next reboot so create the cachedir now.
99 local cachedir="${EPREFIX}/var/cache/pdnsd"
100 if [[ ! -d "${cachedir}" ]] ; then
101 mkdir "${cachedir}" || eerror "Failed to create cache"
103 chown pdnsd:pdnsd "${cachedir}" \
104 || eerror "Failed to set ownership for cachedir"
105 chmod 0750 "${cachedir}" \
106 || eerror "Failed to set permissions for cachedir"