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

# The unbundled Sun Remote Services (SRS) product adds entries to the
# crontab.  SRS cannot run within a zone so we attempt to comment out any of
# these entries that might possibly be present.
#
# 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 (match($0, "/opt/SUNWsrsep") != 0) {
		print "#", $0
		modified=1
	} else {
		print $0
	}
}
END {
	if (modified == 1) {
		printf("# Modified by p2v ")
		system("/usr/bin/date")
		exit 0
	}
	exit 1
}' /var/spool/cron/crontabs/root >/tmp/crontab.$$

if [ $? -eq 0 ]; then
	if [ ! -f /var/spool/cron/root_crontab.pre_p2v ]; then
		cp -p /var/spool/cron/crontabs/root \
		    /var/spool/cron/root_crontab.pre_p2v
	fi
	cp /tmp/crontab.$$ /var/spool/cron/crontabs/root
fi
rm -f /tmp/crontab.$$
