#!/bin/sh
#
errlevel=0

queryProperty IntelBIOSID BoardFamilyID S3000
if [ $? = 0 ];
then 
    echo This script only works on a S3000 system
    exit 1 
fi

queryProperty BIOSRAID SWRAID Enabled
if [ $? = 0 ];
then 
    # setup BIOS for RAID
    setBIOS4RAID enable SATA
    exit 1 
fi

queryProperty BIOSRAID Vendor LSI
if [ $? = 0 ];
then 
    # setup BIOS for RAID
    call setBIOS4RAID enable SATA
    exit 1 
fi

#Inquire if the RAID driver is running, and necessary SPY binaries are present
hypercfg /ADP /C0 > /dev/null
if [ $? = 1 ];
then 
	exit 1 
fi

#Clear previous RAID volumes and configuration information and creates RAID1 on ports #0 and #1 without asking for user input.
hypercfg /AM:00,10 /S
if [ $? = 1 ];
then
	exit 1
fi

#Initialize the New Volume
hypercfg /INIT /l0
if [ $? = 1 ];
then
	exit 1
fi

#Set Disk Cache options for Port#0 and Port #1
hypercfg /SETPD /C0 /wc-on /ra-on
hypercfg /SETPD /C1 /wc-on /ra-on
if [ $? = 1 ];
then
	exit 1 
fi

echo A reboot is needed for the driver to recognize the RAID as a single DISK.  
echo Once rebooted, run fdisk to create partition and mkfs -t ext3 /dev/sdxN where /dev/sdxN is the name of the partition to format.
exit $errlevel 
