#!/bin/sh
# 3.3Intel68kPatch.post_install
# 3.3HPPASPARCPatch.post_install
# 
# This script will remove the comment (and blank) lines from the
# /private/etc/hosts and /usr/template/client/etc/hosts files so
# that the YP routines don't go wild. This is needed if you want
# the new lookupd / DNS behavior.
#
# Allan Nathanson, NeXT Computer, 27 September 1995

#
# Files to be updated.
#
HOSTS1="/private/etc/hosts"
HOSTS2="/usr/template/client/etc/hosts"

#
# Check that any files which must exist are actually present.
#
for f in ${HOSTS1} ${HOSTS2}
do
	if [ ! -f ${f} ]; then
		echo "FAILED (The original file, ${f}, does not exist)"
		exit 1
	fi
done

#
# Make the Installer.app log look nice!
#
echo ""

#
# Save copies of files which are present before package installation.
#
for f in ${HOSTS1} ${HOSTS2}
do
	if [ -f ${f}.NS33 ]; then
		echo "        Original version of ${f} already exists."
	else
		/bin/echo -n "        Saving original version of ${f} ... "
		/bin/cp -p ${f} ${f}.NS33
		echo "OK."
	fi
done

#
# Remove comments and blank lines from the flat "hosts" files.
#
for f in ${HOSTS1} ${HOSTS2}
do
	echo -n "        Updating ${f} ... "
	/bin/cp ${f} /tmp/hosts.$$
	/bin/sed -e '/^#/d' -e '/^$/d' /tmp/hosts.$$ > ${f}
	/bin/rm -f /tmp/hosts.$$
	echo "OK."
done

#
# Make the package installation log look nice!
#
echo "    ... done."

exit 0
