#!/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.


# the path to the PID file
PIDFILE=/var/run/isi_boot_d.pid

eval `limits -e -C daemon` >/dev/null 2>&1

ERROR=0
ARGV="$@"
if [ "x$ARGV" = "x" ] ; then 
    ARGS="help"
fi

for ARG in $@ $ARGS
do
    # check for pidfile
    if [ -f $PIDFILE ] ; then
	PID=`cat $PIDFILE`
	if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
	    RUNNING=1
	else
	    RUNNING=0
	fi
    else
	RUNNING=0
    fi

    case $ARG in
    start)
	if [ $RUNNING -eq 1 ]; then
	    continue
	fi
	/usr/sbin/isi_boot_d
	;;
    stop)
	if [ $RUNNING -eq 0 ]; then
	    continue
	fi
	/bin/kill -QUIT $PID
	;;
    *)
	echo "usage: $0 (start|stop|help)"
	cat <<EOF

start      - start isi_boot_d 
stop       - stop isi_boot_d 
help       - this screen

EOF
	ERROR=2
    ;;

    esac

done

exit $ERROR
