Home | History | Annotate | Download | only in common_files
      1 #!/bin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 #ident	"%Z%%M%	%I%	%E% SMI"
     23 #
     24 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 
     27 PATH="/usr/bin:/usr/sbin:${PATH}"
     28 export PATH
     29 
     30 rtc='#
     31 # The rtc command is run to adjust the real time clock if and when 
     32 # daylight savings time changes.
     33 #
     34 1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1'
     35 
     36 while read src dest
     37 do
     38 	if [ ! -f $dest ] ; then
     39 		cp $src $dest
     40 		if [ $ARCH = i386 ]; then
     41 			#
     42 			# add rtc into root crontab entry
     43 			# 
     44 			echo "$rtc" >> $dest
     45 		fi 
     46 	else
     47 		#
     48 		# 2.1 version of this file had a trailing blank line.
     49 		# Remove it.
     50 		#
     51 		sed -e '$s/^[ 	]*$/%%%/' -e '/^%%%$/d' $dest > /tmp/d.$$
     52 		cp /tmp/d.$$ $dest
     53 		#
     54 		# use nfsfind and reduce frequency from everyday to once a week 
     55 		# without overriding the local admins changes
     56 		#
     57 		sed -e 's,find / -name \.nfs\\\* -mtime +7.*,/usr/lib/fs/nfs/nfsfind,' \
     58 		    -e 's,\* \* \* /usr/lib/fs/nfs/nfsfind,\* \* 0 /usr/lib/fs/nfs/nfsfind,' \
     59 		    -e 's,\([^&]\) /usr/lib/fs/nfs/nfsfind$,\1 \[ -x /usr/lib/fs/nfs/nfsfind \] \&\& /usr/lib/fs/nfs/nfsfind,' $dest > /tmp/d.$$
     60 		cp /tmp/d.$$ $dest
     61 		#
     62 		# logchecker goes away
     63 		#
     64 		sed -e '/[^#]*[ 	]*\/etc\/cron.d\/logchecker/d' $dest > /tmp/d.$$
     65 		cp /tmp/d.$$ $dest
     66 		#
     67 		# newsyslog goes away if the entry hasn't been modifed
     68 		#
     69 		sed -e '/10 3 \* \* 0[ 	]*\/usr\/lib\/newsyslog/d' $dest > /tmp/d.$$
     70 		cp /tmp/d.$$ $dest
     71 		#
     72 		# add logadm command
     73 		#
     74 		grep /usr/sbin/logadm $dest >/dev/null 2>&1
     75 		if [ $? != 0 ] ; then
     76 			grep /usr/sbin/logadm $src >> $dest
     77 		fi
     78 		#
     79 		# add rtc entry if its missing for i386
     80 		# delete rtc entry for sparc and other ARCH
     81 		#
     82 		if [ $ARCH = i386 ]; then
     83 			grep /usr/sbin/rtc  $dest >/dev/null 2>&1
     84 			if [ $? != 0 ] ; then
     85 				echo "$rtc" >> $dest
     86 			fi
     87 		else
     88 			grep /usr/sbin/rtc  $dest >/dev/null 2>&1
     89 			if [ $? = 0 ] ; then
     90 				sed -e '/^.*\/usr\/sbin\/rtc.*$/d' \
     91 				    -e '/^# The rtc command is run/,/^#$/d' \
     92 				    $dest > /tmp/cron.$$
     93 				mv /tmp/cron.$$  $dest
     94 			fi	
     95 				
     96 		fi
     97 		#
     98 		# take nptdate out of crontab. It was added in Beta 2.6.
     99 		# Make sure it is gone evermore.
    100 		#
    101 		grep "/usr/lib/inet/ntpdate" $dest >/dev/null 2>&1
    102 		if [ $? -eq 0 ] ; then
    103 			sed ' 
    104 				/^.*\/usr\/lib\/inet\/ntpdate.*$/ {
    105 				d
    106 				} ' $dest > /tmp/cron.$$
    107 			mv /tmp/cron.$$ $dest
    108 		fi
    109 		#
    110 		# ftpclean was added in 2.7 (pre-beta) but will
    111 		# not be shipping in 2.7. Remove cron entry
    112 		#
    113 		grep "/usr/lib/inet/ftpclean" $dest >/dev/null 2>&1
    114 		if [ $? -eq 0 ]; then
    115 		    sed -e '/^.*\/usr\/lib\/inet\/ftpclean.*$/d' $dest >/tmp/cron.$$
    116 		    mv /tmp/cron.$$ $dest
    117 		fi
    118 		#
    119 		# add gsscred duplicates clean-up script - SUNWgss
    120 		#
    121 		grep "/usr/lib/gss/gsscred_clean" $dest >/dev/null 2>&1
    122 		if [ $? != 0 ] ; then
    123 			grep "/usr/lib/gss/gsscred_clean" $src >> $dest
    124 		fi
    125 	fi
    126 done
    127 
    128 exit 0
    129