#!/bin/sh

# Copyright C 2002-2003 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.
#
# PROVIDE: isi_corefile
# REQUIRE: isi_bootdisk_init
# BEFORE: initrandom
# Run this as soon after /var/crash is mounted as possible.
#
crashpath=/var/crash;
stripeid=/var/crash/stripe.id;

if [ -r /etc/defaults/rc.conf ]; then
	. /etc/defaults/rc.conf
	source_rc_confs
elif [ -r /etc/rc.conf ]; then
	. /etc/rc.conf
fi

case ${dumppid} in
[Yy][Ee][Ss])	
	sysctl -w kern.corefile=$crashpath/"%N.core.%P" > /dev/null;
	;;
*)
	sysctl -w kern.corefile=$crashpath/"%N.core" > /dev/null;
esac
		
if [ -e $stripeid ];then
	id=`cat $stripeid`;
else
	id=`echo $HOSTNAME | awk -F '.' '{print $1}'`;
fi

if kldstat -n efs.ko > /dev/null; then
	/etc/dbline.pl > /dev/null
fi

# The following line are commented out until we are able to enable this
# when we aren't having problems with touch

#newcorepath=`mount | grep efs | awk '{print \$3}'`/.ifsvar;
#if [[ ! -d $newcorepath ]]; then mkdir $newcorepath; fi
#newcorepath=$newcorepath/core;
#if [[ ! -d $newcorepath ]]; then mkdir $newcorepath; fi
#newcorepath=$newcorepath/$id; 
#if [[ ! -d $newcorepath ]]; then 
#	mkdir $newcorepath; 
#else
#	rm $newcorepath/*;
#	echo -n "These files will be found on /var/crash" > $newcorepath/README;
#	echo " of the machine whose id matches" >> $newcorepath/README;
#	echo "the parent directory of this file" >> $newcorepath/README; 
#fi

#for i in $crashpath/*; do
#	if [[ $i != $crashpath/minfree && $i != $crashpath/bounds &&
#	      $i != $stripeid ]];then
#		touch $newcorepath/`echo $i | awk -F '/' '{print $4}'`
#	fi
#done
