Gentoo Archives: gentoo-user

From: Pandu Poluan <pandu@××××××.info>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] /etc/hosts include file?
Date: Fri, 08 Mar 2013 04:30:56
Message-Id: CAA2qdGVHxS1NgtCgpbDhNoTfWPK-szgRJCN_yae5e_EenTYNxA@mail.gmail.com
In Reply to: [gentoo-user] /etc/hosts include file? by Alan McKinnon
1 On Mar 8, 2013 5:27 AM, "Alan McKinnon" <alan.mckinnon@×××××.com> wrote:
2 >
3 > Anyone know if there's a way to get /etc/hosts to support the notion of
4 > an include file? I did my homework and found nothing, maybe someone else
5 > knows more.
6 >
7 > I really do need this, I have an app that discovers things on the
8 > network and knows their address. This makes it's automated way into DNS
9 > but takes a few days, and another app needs to use the fqdn right now.
10 > So /etc/hosts is the way to go for the interim three days.
11 >
12 > I've worked around it by creating /etc/hosts.d/ containing a header and
13 > a data file. cat the two and redirect to /etc/hosts.d/hosts and the real
14 > hosts file is a symlink to that. It's a sub-directory as none of these
15 > apps run as root and only root can modiy the real hosts file.
16 >
17 > This works well enough, but a supported include mechanism would make
18 > life so much simpler, not to mention easier for my colleagues to
19 > understand what the blazes I set up :-)
20 >
21 >
22 >
23 > --
24 > Alan McKinnon
25 > alan.mckinnon@×××××.com
26 >
27 >
28 >
29
30 An option would be to create a cron job which generates the hosts file
31 every minute. The cron job should also insert a header on top of the hosts
32 file telling:
33
34 + this file (hosts) is dynamically generated
35 + by a system cron job
36 + the cron job's script location
37
38 Besides, you said you're going to need this workaround only for a couple of
39 days, so installing Samba4 might be an overkill.
40
41
42 Rgds,
43 --

Replies

Subject Author
Re: [gentoo-user] /etc/hosts include file? Alan McKinnon <alan.mckinnon@×××××.com>