summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Portnoy <avenj@gentoo.org>2006-09-13 04:39:52 +0000
committerJon Portnoy <avenj@gentoo.org>2006-09-13 04:39:52 +0000
commit0d4685f313503c4aeeaed24ca70678b99de2095e (patch)
tree8304bd5f6834eaeb9a0f8e440320fe9e3af85689 /net-dns
parentAdd resolvconf flag for dnsmasq (diff)
downloadgentoo-2-0d4685f313503c4aeeaed24ca70678b99de2095e.tar.gz
gentoo-2-0d4685f313503c4aeeaed24ca70678b99de2095e.tar.bz2
gentoo-2-0d4685f313503c4aeeaed24ca70678b99de2095e.zip
Added resolvconf support
(Portage version: 2.1.1_rc1)
Diffstat (limited to 'net-dns')
-rw-r--r--net-dns/dnsmasq/ChangeLog5
-rw-r--r--net-dns/dnsmasq/dnsmasq-2.33.ebuild12
-rw-r--r--net-dns/dnsmasq/files/resolvconf.dnsmasq89
3 files changed, 102 insertions, 4 deletions
diff --git a/net-dns/dnsmasq/ChangeLog b/net-dns/dnsmasq/ChangeLog
index e97bf5204809..646012b97fe2 100644
--- a/net-dns/dnsmasq/ChangeLog
+++ b/net-dns/dnsmasq/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for net-dns/dnsmasq
# Copyright 2002-2006 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-dns/dnsmasq/ChangeLog,v 1.99 2006/09/04 05:47:15 kumba Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-dns/dnsmasq/ChangeLog,v 1.100 2006/09/13 04:39:52 avenj Exp $
+
+ 13 Sep 2006; Jon Portnoy <avenj@gentoo.org> dnsmasq-2.33.ebuild :
+ Added net-dns/resolvconf support
04 Sep 2006; Joshua Kinard <kumba@gentoo.org> dnsmasq-2.31.ebuild:
Marked stable on mips.
diff --git a/net-dns/dnsmasq/dnsmasq-2.33.ebuild b/net-dns/dnsmasq/dnsmasq-2.33.ebuild
index e27c21d275a9..001a0e858ca5 100644
--- a/net-dns/dnsmasq/dnsmasq-2.33.ebuild
+++ b/net-dns/dnsmasq/dnsmasq-2.33.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-dns/dnsmasq/dnsmasq-2.33.ebuild,v 1.1 2006/08/07 16:51:56 avenj Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-dns/dnsmasq/dnsmasq-2.33.ebuild,v 1.2 2006/09/13 04:39:52 avenj Exp $
inherit eutils toolchain-funcs
@@ -13,11 +13,12 @@ SRC_URI="http://www.thekelleys.org.uk/dnsmasq/${MY_P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~s390 ~sh ~sparc ~x86"
-IUSE=""
+IUSE="resolvconf"
RDEPEND=""
DEPEND="${RDEPEND}
- >=sys-apps/portage-2.0.51"
+ >=sys-apps/portage-2.0.51
+ resolvconf? ( net-dns/resolvconf-gentoo )"
S=${WORKDIR}/${PN}-${MY_PV}
@@ -43,4 +44,9 @@ src_install() {
newconfd "${FILESDIR}"/dnsmasq.confd dnsmasq
insinto /etc
newins dnsmasq.conf.example dnsmasq.conf
+
+ if use resolvconf ; then
+ insinto /etc/resolvconf/update.d
+ newins ${FILESDIR}/resolvconf.dnsmasq dnsmasq
+ fi
}
diff --git a/net-dns/dnsmasq/files/resolvconf.dnsmasq b/net-dns/dnsmasq/files/resolvconf.dnsmasq
new file mode 100644
index 000000000000..423769a0dd5c
--- /dev/null
+++ b/net-dns/dnsmasq/files/resolvconf.dnsmasq
@@ -0,0 +1,89 @@
+#!/bin/bash
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# dnsmasq-resolv.conf updater
+# Written by Roy Marples (uberlord@gentoo.org)
+
+# This is very important!
+# We assume that we are a local dns cache - after all, why would a server
+# use resolvconf?
+# Now that we have assumed this, we also assume that generic DHCP clients
+# will enter their domains and search domains ONLY in the "search" field
+# in their resolv.confs and VPN clients will put the domain they are for
+# into the domain field only.
+# This allows dnsmasq to forward domains for a specific VPN domain to the
+# VPN nameserver and everything else to the standard name servers.
+
+# A sample dnsmasq config that works as above is like so
+#domain-needed
+#interface=lo
+#conf-file=/etc/dnsmasq-resolvconf.conf
+#resolv-file=/etc/dnsmasq-resolv.conf
+
+# The last step is to configure dns configuration for /etc/resolv.conf
+# for the lo interface. In Gentoo we set it up like so in /etc/conf.d/net
+#dns_servers_lo=( "127.0.0.1" )
+
+# Load generic Gentoo functions
+source /etc/init.d/functions.sh
+
+# Load our variables from resolvconf
+VARS="$(resolvconf -v)"
+eval "${VARS}"
+
+DNSMASQRESOLV="/etc/dnsmasq-resolv.conf"
+DNSMASQCONF="/etc/dnsmasq-resolvconf.conf"
+
+NEWCONF="# Generated by resolvconf"
+NEWRESOLV="${NEWCONF}\nsearch"
+
+# If we only have domain information then put it in search too
+[[ -z ${NEWSEARCH} && -z ${NEWNS} ]] && NEWSEARCH="${NEWDOMAIN}"
+
+for N in ${NEWSEARCH} ; do
+ if [[ " ${NEWSL} " != *" ${N%,*} "* ]] ; then
+ NEWSL="${NEWSL} ${N%,*}"
+ fi
+ if [[ "\n${NEWRESOLV}\n" != *"\nnameserver ${N#*,}\n"* ]] ; then
+ NEWRESOLV="${NEWRESOLV}\nnameserver ${N#*,}"
+ fi
+done
+for N in ${NEWNS} ; do
+ if [[ "\n${NEWRESOLV}\n" != *"\nnameserver ${N}\n" ]] ; then
+ NEWRESOLV="${NEWRESOLV}\nnameserver ${N}"
+ fi
+done
+NEWRESOLV="${NEWRESOLV//\\nsearch/${NEWSL:+\nsearch${NEWSL}}}"
+
+for DN in $(uniqify ${NEWDOMAIN}) ; do
+ NEWCONF="${NEWCONF}\nserver=/${DN%,*}/${DN#*,}"
+done
+
+RELOAD="no"
+if [[ -e ${DNSMASQCONF} ]] ; then
+ if [[ $(< "${DNSMASQCONF}") != "$(echo -e "${NEWCONF}")" ]] ; then
+ RELOAD="yes"
+ echo -e "${NEWCONF}" > "${DNSMASQCONF}"
+ fi
+else
+ RELOAD="yes"
+ echo -e "${NEWCONF}" > "${DNSMASQCONF}"
+fi
+if [[ -e ${DNSMASQRESOLV}} ]] ; then
+ if [[ $(< "${DNSMASQRESOLV}") != "$(echo -e "${NEWRESOLV}")" ]] ; then
+ RELOAD="yes"
+ echo -e "${NEWRESOLV}" > "${DNSMASQRESOLV}"
+ fi
+else
+ # dnsmasq polls this file so no need to set RELOAD="yes"
+ echo -e "${NEWRESOLV}" > "${DNSMASQRESOLV}"
+fi
+
+if [[ ${RELOAD} == "yes" && -x /etc/init.d/dnsmasq ]] ; then
+ if /etc/init.d/dnsmasq --quiet status ; then
+ /etc/init.d/dnsmasq --quiet --nodeps restart
+ fi
+fi
+
+# vim: ts=4 :