5 # Start local DNS server to provide minimal DNS forward resolution for
6 # ourselves and our nodes.
8 # Mark Huang <mlhuang@cs.princeton.edu>
9 # Copyright (C) 2006 The Trustees of Princeton University
14 # Source function library and configuration
15 . /etc/plc.d/functions
16 . /etc/planetlab/plc_config
18 SIGNATURE="; generated by /etc/plc.d/dns --- DO NOT REMOVE THIS TEXT!"
25 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
26 MESSAGE="Starting DNS server"
34 if [ -n "$PLC_NET_DNS1" -o -n "$PLC_NET_DNS2" ] ; then
35 MESSAGE="Configuring resolv.conf"
41 [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1"
42 [ -n "$PLC_NET_DNS2" -a "$PLC_NET_DNS1" != "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2"
45 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
46 ourfile=$(grep "$SIGNATURE" /etc/resolv.conf| wc -l)
47 if [ $ourfile -eq 0 ] ; then
48 cp /etc/resolv.conf /etc/plc_resolv.conf
51 cp /etc/resolv.conf /etc/resolv_plc.backup
53 mv -f $rfile /etc/resolv.conf
54 chmod 444 /etc/resolv.conf
57 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
66 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
67 MESSAGE=$"Reverting /etc/resolv.conf"
69 if [ -f "/etc/plc_resolv.conf" ] ; then
70 ourfile=$(grep "$SIGNATURE" /etc/plc_resolv.conf| wc -l)
71 if [ $ourfile -ne 0 ] ; then
72 dialog "WARNING: original /etc/resolv.conf was generated by etc/plc.d/dns"
74 mv -f /etc/plc_resolv.conf /etc/resolv.conf
78 MESSAGE=$"Removing /etc/plc_hosts"
80 [ -f "/etc/plc_hosts" ] && rm -f /etc/plc_hosts
83 if [ $PLC_DNS_ENABLED -eq 0 -a -f "/etc/resolv_plc.backup" ] ; then
84 MESSAGE="Restoring /etc/resolv.conf"
86 mv -f /etc/resolv_plc.backup /etc/resolv.conf
90 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
91 MESSAGE="Stopping DNS server"