#!/bin/sh

if test ! -e /etc/nsswitch.conf.pre-mdns; then
	echo  >/etc/nsswitch.conf "passwd:      files"
	echo >>/etc/nsswitch.conf "group:       files"
	echo >>/etc/nsswitch.conf "hosts:       files dns"
	echo >>/etc/nsswitch.conf "networks:    files dns"
	echo >>/etc/nsswitch.conf "services:    files"
	echo >>/etc/nsswitch.conf "protocols:   files"
else
        # don't remove by using pre-mdns file...
#	mv /etc/nsswitch.conf.pre-mdns /etc/nsswitch.conf
	sed -e 's/^\(hosts:.*\)mdns dns\(.*\)/\1dns\2/' /etc/nsswitch.conf > /etc/nsswitch.conf.post-mdns
	if test ! -e /etc/nsswitch.conf.post-mdns; then
		echo "Can't create file /etc/nsswitch.conf.post-mdns"
		exit 1
	fi
	mv /etc/nsswitch.conf.post-mdns /etc/nsswitch.conf
	if test ! -e /etc/nsswitch.conf; then
		echo "Can't create file /etc/nsswitch.conf"
	else
		chmod a+r /etc/nsswitch.conf
		rm -f /etc/nsswitch.conf.pre-mdns
	fi
fi
