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 MESSAGE=$"Reverting /etc/resolv.conf and /etc/hosts"
68 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
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
76 [ -f "/etc/plc_hosts" ] && rm -f /etc/plc_hosts
78 if [ $PLC_DNS_ENABLED -eq 0 -a -f "/etc/resolv_plc.backup" ] ; then
79 mv -f /etc/resolv_plc.backup /etc/resolv.conf
82 if [ $PLC_DNS_ENABLED -eq 1 ] ; then
83 MESSAGE=$"Stopping DNS server"