#!/bin/sh

PID=$$
TMP_FILE=/tmp/netapp_san_inst_$PID
INS_DIR=/opt/netapp
INS_BIN_DIR=/opt/netapp/santools
DATE=`date +%Y%m%d_%H%M`

# Ensure the user is running as root
USER=`/usr/bin/whoami`

if [ "$USER" != "root" ]
then
        echo
        echo This install program must be run as root.
        echo
        exit 1
fi

# See if there is already a sanlun installed 
if [ -d $INS_DIR ] ; then
	# There is an /opt/netapp/santools dir present move it aside
	echo "$INS_DIR exists, moving to $INS_DIR$DATE"
	/bin/mv $INS_DIR $INS_DIR$DATE
fi;

# create /opt/netapp/santools and install the stuff
/bin/mkdir -p $INS_BIN_DIR

# put all the stuff there
here=`pwd`
cd /; tar -xvf $here/sanlun_bin_netapp.tar

# make a link in /usr/sbin to sanlun
ln -s /opt/netapp/santools/sanlun /usr/sbin/sanlun

exit 0;
