#!/sbin/sh
#
# @(#) $Revision: 72.7 $
#
# NOTE:    This script is not configurable!  Any changes made to this
#          scipt will be overwritten when you upgrade to the next
#          release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
#          is unbootable.  Do not modify this script.
#

#
# List and/or clear temporary files
#

PATH=/sbin:/usr/sbin:/usr/bin
export PATH


case $1 in
start_msg)
	echo "List and/or clear temporary files"
	;;

'start')
	if [ -f /etc/rc.config.d/clean_tmps ] ; then
		. /etc/rc.config.d/clean_tmps
	else
		echo "ERROR: /etc/rc.config.d/clean_tmps defaults file MISSING"
	fi
	
	if [ "$CLEAR_TMP" -eq 1 ]; then
		echo "NOTE:  Clearing files from /tmp"

# If /tmp, or anything beneath /tmp, is a mount point, or if /tmp is a
# symbolic link, do not remove it; just purge the contents.

		TMOUNT=`/sbin/mount | egrep '^/tmp(/| )' | wc -l`

		if [[ $TMOUNT -ne 0 || -h /tmp ]]
	        then
			rm -rf /tmp/* /tmp/.*
		else
			rm -rf /tmp
			mkdir /tmp
			chmod 1777 /tmp
			chgrp root /tmp
			chown root /tmp
		fi
	fi

	if [ "$LIST_TEMPS" -eq 1 ]; then
		for dir in /tmp /var/tmp /lost+found
		do
			if [ -d "$dir" ]; then
			    if [ "`ls -A $dir`" ]; then
				echo "NOTE:  Files in $dir:"
				ls -lA $dir
			    fi
			fi
		done
	else
		rval=2
	fi
	;;

*)
	echo "usage: $0 {start}"
	;;
esac

exit 0
