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 cp $rfile /etc/plc_resolv.conf
47 chmod 444 /etc/plc_resolv.conf
48 ourfile=$(grep "$SIGNATURE" /etc/resolv.conf| wc -l)
49 if [ $ourfile -eq 0 ] ; then
50 cp /etc/resolv.conf /etc/resolv.bak
51 echo $SIGNATURE > /etc/resolv.conf
52 echo nameserver 127.0.0.1 >> /etc/resolv.conf
53 chmod 444 /etc/resolv.conf
56 cp /etc/resolv.conf /etc/resolv.bak
57 mv -f $rfile /etc/resolv.conf
58 chmod 444 /etc/resolv.conf
62 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
71 MESSAGE=$"Reverting /etc/resolv.conf"
73 if [ -f "/etc/resolv.bak" ] ; then
74 ourfile=$(grep "$SIGNATURE" /etc/resolv.bak | wc -l)
75 if [ $ourfile -ne 0 ] ; then
76 dialog "WARNING: original /etc/resolv.conf was generated by etc/plc.d/dns"
78 mv -f /etc/resolv.bak /etc/resolv.conf
82 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
83 MESSAGE=$"Removing /etc/plc_hosts"
85 [ -f "/etc/plc_hosts" ] && rm -f /etc/plc_hosts
89 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
90 MESSAGE="Stopping DNS server"