OpenSolaris_b135/pkgdefs/common_files/i.cronroot

#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#ident	"%Z%%M%	%I%	%E% SMI"
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.

PATH="/usr/bin:/usr/sbin:${PATH}"
export PATH

rtc='#
# The rtc command is run to adjust the real time clock if and when 
# daylight savings time changes.
#
1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1'

while read src dest
do
	if [ ! -f $dest ] ; then
		cp $src $dest
		if [ $ARCH = i386 ]; then
			#
			# add rtc into root crontab entry
			# 
			echo "$rtc" >> $dest
		fi 
	else
		#
		# 2.1 version of this file had a trailing blank line.
		# Remove it.
		#
		sed -e '$s/^[ 	]*$/%%%/' -e '/^%%%$/d' $dest > /tmp/d.$$
		cp /tmp/d.$$ $dest
		#
		# use nfsfind and reduce frequency from everyday to once a week 
		# without overriding the local admins changes
		#
		sed -e 's,find / -name \.nfs\\\* -mtime +7.*,/usr/lib/fs/nfs/nfsfind,' \
		    -e 's,\* \* \* /usr/lib/fs/nfs/nfsfind,\* \* 0 /usr/lib/fs/nfs/nfsfind,' \
		    -e 's,\([^&]\) /usr/lib/fs/nfs/nfsfind$,\1 \[ -x /usr/lib/fs/nfs/nfsfind \] \&\& /usr/lib/fs/nfs/nfsfind,' $dest > /tmp/d.$$
		cp /tmp/d.$$ $dest
		#
		# logchecker goes away
		#
		sed -e '/[^#]*[ 	]*\/etc\/cron.d\/logchecker/d' $dest > /tmp/d.$$
		cp /tmp/d.$$ $dest
		#
		# newsyslog goes away if the entry hasn't been modifed
		#
		sed -e '/10 3 \* \* 0[ 	]*\/usr\/lib\/newsyslog/d' $dest > /tmp/d.$$
		cp /tmp/d.$$ $dest
		#
		# add logadm command
		#
		grep /usr/sbin/logadm $dest >/dev/null 2>&1
		if [ $? != 0 ] ; then
			grep /usr/sbin/logadm $src >> $dest
		fi
		#
		# add rtc entry if its missing for i386
		# delete rtc entry for sparc and other ARCH
		#
		if [ $ARCH = i386 ]; then
			grep /usr/sbin/rtc  $dest >/dev/null 2>&1
			if [ $? != 0 ] ; then
				echo "$rtc" >> $dest
			fi
		else
			grep /usr/sbin/rtc  $dest >/dev/null 2>&1
			if [ $? = 0 ] ; then
				sed -e '/^.*\/usr\/sbin\/rtc.*$/d' \
				    -e '/^# The rtc command is run/,/^#$/d' \
				    $dest > /tmp/cron.$$
				mv /tmp/cron.$$  $dest
			fi	
				
		fi
		#
		# take nptdate out of crontab. It was added in Beta 2.6.
		# Make sure it is gone evermore.
		#
		grep "/usr/lib/inet/ntpdate" $dest >/dev/null 2>&1
		if [ $? -eq 0 ] ; then
			sed ' 
				/^.*\/usr\/lib\/inet\/ntpdate.*$/ {
				d
				} ' $dest > /tmp/cron.$$
			mv /tmp/cron.$$ $dest
		fi
		#
		# ftpclean was added in 2.7 (pre-beta) but will
		# not be shipping in 2.7. Remove cron entry
		#
		grep "/usr/lib/inet/ftpclean" $dest >/dev/null 2>&1
		if [ $? -eq 0 ]; then
		    sed -e '/^.*\/usr\/lib\/inet\/ftpclean.*$/d' $dest >/tmp/cron.$$
		    mv /tmp/cron.$$ $dest
		fi
		#
		# add gsscred duplicates clean-up script - SUNWgss
		#
		grep "/usr/lib/gss/gsscred_clean" $dest >/dev/null 2>&1
		if [ $? != 0 ] ; then
			grep "/usr/lib/gss/gsscred_clean" $src >> $dest
		fi
	fi
done

exit 0