enable local DNS server that can provide minimal forward DNS resolution for MyPLC...
[myplc.git] / plc.d / dns
1 #!/bin/bash
2 #
3 # priority: 850
4 #
5 # Start local DNS server to provide minimal DNS forward resolution for
6 # ourselves and our nodes.
7 #
8 # Mark Huang <mlhuang@cs.princeton.edu>
9 # Copyright (C) 2006 The Trustees of Princeton University
10 #
11 # $Id: mail,v 1.2 2006/04/25 21:18:19 mlhuang Exp $
12 #
13
14 # Source function library and configuration
15 . /etc/plc.d/functions
16 . /etc/planetlab/plc_config
17
18 case "$1" in
19     start)
20         if [ "$PLC_DNS_ENABLED" != "1" ] ; then
21             exit 0
22         fi
23
24         MESSAGE=$"Starting DNS server"
25         dialog "$MESSAGE"
26
27         # From the default dnsmasq.conf configuration file:
28         #
29         # The [domain-needed and bogus-priv] options make you a better
30         # netizen, since they tell dnsmasq to filter out queries which
31         # the public DNS cannot answer, and which load the servers
32         # (especially the root servers) uneccessarily.
33         #
34         # The api-config bootstrap script writes node hostnames to
35         # /etc/plc_hosts.
36         #
37         cat >/etc/dnsmasq.conf <<EOF
38 domain-needed
39 bogus-priv
40 addn-hosts=/etc/plc_hosts
41 EOF
42
43         plc_daemon dnsmasq
44         check
45
46         result "$MESSAGE"
47         ;;
48
49     stop)
50         MESSAGE=$"Stopping DNS server"
51         dialog "$MESSAGE"
52
53         killproc plc_dnsmasq
54         check
55
56         result "$MESSAGE"
57         ;;
58 esac
59
60 exit $ERRORS