X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc.d%2Fdns;h=afdf55ffd4ad5fcfa26d512cad2eef0a6db16a90;hb=039b8b04f1e3e9f584abf83797ae3f1a8c421e23;hp=446c21f25716962da1cda860d0d4c6bb5db490e9;hpb=2fdcbfd7f3cf30b5bb9e5641294d3c02a3e24db7;p=myplc.git diff --git a/plc.d/dns b/plc.d/dns index 446c21f..afdf55f 100755 --- a/plc.d/dns +++ b/plc.d/dns @@ -1,6 +1,6 @@ #!/bin/bash # -# priority: 850 +# priority: 950 # # Start local DNS server to provide minimal DNS forward resolution for # ourselves and our nodes. @@ -8,52 +8,91 @@ # Mark Huang # 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 +SIGNATURE="; generated by /etc/plc.d/dns --- DO NOT REMOVE THIS TEXT" + +# Be verbose +set -x + case "$1" in start) - if [ "$PLC_DNS_ENABLED" != "1" ] ; then - exit 0 + if [ $PLC_DNS_ENABLED -eq 1 ] ; then + MESSAGE="Starting DNS server" + dialog "$MESSAGE" + + dns-config + check + fi + + # Set up nameservers + if [ -n "$PLC_NET_DNS1" -o -n "$PLC_NET_DNS2" ] ; then + MESSAGE="Configuring resolv.conf" + dialog "$MESSAGE" + + rfile=$(mktemp) + ( + echo $SIGNATURE + [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1" + [ -n "$PLC_NET_DNS2" -a "$PLC_NET_DNS1" != "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2" + ) > $rfile + + if [ $PLC_DNS_ENABLED -eq 1 ] ; then + ourfile=$(grep "$SIGNATURE" /etc/resolv.conf| wc -l) + if [ $ourfile -eq 0 ] ; then + cp /etc/resolv.conf /etc/plc_resolv.conf + fi + else + cp /etc/resolv.conf /etc/resolv_plc.backup + fi + mv -f $rfile /etc/resolv.conf + chmod 444 /etc/resolv.conf 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 <