#!/bin/sh
#
# load_cyc-z-fw	This shell script takes care of loading the cyclom-Z firmware
#		if cyclom-Z pods are present.
#
# chkconfig: 2345 80 10
# description: This program checks to see if the Cyclom-Z hardware is installed
#	       and if it is, loads the firmware in /usr/local/lib/cyzfirm.bin
#	       using the /usr/local/sbin/cyzload util.	
#


PATH=/sbin:/usr/local/sbin:/usr/farm/bin:$PATH
export PATH
B="[1m"
N="[0m"



case "$1" in
        start)  
             	if [ ! "`lspci | grep -i Cyclades-Z`" = "" ]; then
			echo "Cyclades-Z hardware detected."
			echo "Loading cyclades module."
			modprobe cyclades
			sleep 10
			echo "Loading Cyclades-Z firmware..." 
			cyzload
			echo "Restarting console server process."
			startserver
		fi
                ;;
	stop)
             	if [ ! "`lspci | grep -i Cyclades-Z`" = "" ]; then
			echo "Cyclades-Z hardware detected."
			echo "Stop console processes..."
			stopserver
			sleep 10
			echo "Removing cyclades module."
			rmmod cyclades
		fi
		;;
        *)      echo "Usage: $0 [${B}start|stop${N}]"
                exit 1
                ;;

esac
echo "done."
