#!/bin/sh
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)S33_fix_vfstab.sh	1.1	08/05/06 SMI"
#

# Comment out most of the old mounts since they are either unneeded or
# likely incorrect within a zone.  Specific mounts can be manually 
# reenabled if the corresponding device is added to the zone.
#
# As part of the p2v module interface there are environment variables set for
# this script (e.g. FILEDIR - path to brand-specific file repository).
# See the p2v script for a full list of variables.
#

nawk '{
	if (substr($1, 0, 1) == "#") {
		print $0
	} else if ($1 == "fd" || $1 == "/proc" || $1 == "swap" ||
	    $4 == "nfs" || $4 == "lofs") {
		print $0
	} else {
		print "#", $0
		modified=1
	}
}
END {
	if (modified == 1) {
		printf("# Modified by p2v ")
		system("/usr/bin/date")
		exit 0
	}
	exit 1
}' /etc/vfstab >/tmp/vfstab.$$

if [ $? -eq 0 ]; then
	if [ ! -f /etc/vfstab.pre_p2v ]; then
		cp -p /etc/vfstab /etc/vfstab.pre_p2v
	fi
	cp /tmp/vfstab.$$ /etc/vfstab
fi
rm -f /tmp/vfstab.$$
