From: Mark Huang <mlhuang@cs.princeton.edu>
Date: Tue, 23 May 2006 18:10:08 +0000 (+0000)
Subject: enable local DNS server that can provide minimal forward DNS resolution for MyPLC... 
X-Git-Tag: myplc-0_4-rc1~27
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=2fdcbfd7f3cf30b5bb9e5641294d3c02a3e24db7;p=myplc.git

enable local DNS server that can provide minimal forward DNS resolution for MyPLC and its nodes
---

diff --git a/plc.d/dns b/plc.d/dns
new file mode 100755
index 0000000..446c21f
--- /dev/null
+++ b/plc.d/dns
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# priority: 850
+#
+# Start local DNS server to provide minimal DNS forward resolution for
+# ourselves and our nodes.
+#
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2006 The Trustees of Princeton University
+#
+# $Id: mail,v 1.2 2006/04/25 21:18:19 mlhuang Exp $
+#
+
+# Source function library and configuration
+. /etc/plc.d/functions
+. /etc/planetlab/plc_config
+
+case "$1" in
+    start)
+	if [ "$PLC_DNS_ENABLED" != "1" ] ; then
+	    exit 0
+	fi
+
+	MESSAGE=$"Starting DNS server"
+	dialog "$MESSAGE"
+
+	# From the default dnsmasq.conf configuration file:
+	#
+	# The [domain-needed and bogus-priv] options make you a better
+	# netizen, since they tell dnsmasq to filter out queries which
+	# the public DNS cannot answer, and which load the servers
+	# (especially the root servers) uneccessarily.
+	#
+	# The api-config bootstrap script writes node hostnames to
+	# /etc/plc_hosts.
+	#
+	cat >/etc/dnsmasq.conf <<EOF
+domain-needed
+bogus-priv
+addn-hosts=/etc/plc_hosts
+EOF
+
+	plc_daemon dnsmasq
+	check
+
+	result "$MESSAGE"
+	;;
+
+    stop)
+	MESSAGE=$"Stopping DNS server"
+	dialog "$MESSAGE"
+
+	killproc plc_dnsmasq
+	check
+
+	result "$MESSAGE"
+	;;
+esac
+
+exit $ERRORS
diff --git a/plc.d/network b/plc.d/network
index 88ffec0..f84d9aa 100755
--- a/plc.d/network
+++ b/plc.d/network
@@ -7,7 +7,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: network,v 1.2 2006/04/25 21:18:19 mlhuang Exp $
+# $Id: network,v 1.3 2006/05/16 17:09:34 mlhuang Exp $
 #
 
 # Source function library and configuration
@@ -24,9 +24,14 @@ case "$1" in
 	(
 	    for server in API BOOT WWW ; do
 		hostname=PLC_${server}_HOST
-		ip=$(gethostbyname ${!hostname})
-		if [ -n "$ip" ] ; then
-		    echo "$ip	${!hostname}"
+		ip=PLC_${server}_IP
+		if [ -n "${!ip}" ] ; then
+		    echo "${!ip}	${!hostname}"
+		else
+		    ip=$(gethostbyname ${!hostname})
+		    if [ -n "$ip" ] ; then
+			echo "$ip	${!hostname}"
+		    fi
 		fi
 	    done
 	) >>/etc/hosts