#!/bin/csh
clear

## Declare variables and default values
#
set default_host   = `hostname`
set default_sender = "root"
set default_rcpt   = "3ware_admin"
set default_port   = "1080"
set default_help   = "/usr/local/doc/3dm"
set default_extlog = "/var/log/3dmExtLog"
#set default_extlog = ""
# The default password is "3ware"
set default_passwd = "OmwmsK8lKk2"
set rebuild_rate = "25"
set file_name  = "/etc/3dmd.conf"
set version = "v1.00.00.027"
set sw1 = ""
set question = "N"

## Check if user is root
if ("`id -u`" != "0") then
    echo ""
    echo "You must be root or have root privilages to install 3dm."
    echo "3dm installation will stop."
    echo ""
    exit 1
    endif

## Check release.
set release = `uname -s`

if ($release != "Linux") then
    echo ""
    echo "Only Linux is supported by this script. Your system is running $release"
    echo "The script will now exit."
    exit 1
    endif

## Find what argument was used with install.3dm and set $switch to defined value.
# Declare variable
echo $1 | grep '\-i' >/dev/null
set chk1 = $status
#echo "chk1" $chk1
if ($chk1 == "0") then
    set sw1 = "install"
    endif

echo $1 | grep '\-u' >/dev/null
set chk2 = $status
#echo "chk2" $chk2
if ($chk2 == "0") then
    set sw1 = "uninstall"
    endif

echo $1 | grep '\-c' >/dev/null
set chk3 = $status
#echo "chk3" $chk3
if ($chk3 == "0") then
    set sw1 = "configure"
    endif

#    if ($sw1 == "install" || $sw1 == "configure" || $sw1 == "uninstall") then

if ($sw1 == "") then

    if ($1 == "--u" || $1 == "uninstall") then
    	set sw1 = "uninstall"

        else if ($1 == "" || $1 == "--i" || $1 == "install") then
	         set sw1 = "install"

        else if ($1 == "--c" || $1 == "configure") then
    	         set sw1 = "configure"
	
        else
    	    set sw1 = "help"
    	    endif
        endif

echo ""
echo "3ware 3DM installation, configuration and removal script."
echo "(c) 2001 3ware, Inc. All rights reserved."
echo ""
echo "Script version: "$version


## Check for redhat/SuSE release.
#
set distr = "untested"
if ( -e /etc/redhat-release) then
    cat /etc/redhat-release | grep 'Hat' > /dev/null
    if ($status == "0") then
	set distr = "redhat"
    	endif
    endif

if ( -e /etc/SuSE-release) then
    set distr = "suse"
    endif
 
## Check to see if user asked for help. If it was then echo list below.
#
if ($sw1 == "help") then


support:
    clear
    echo "         *********************************************"
    echo "         *   Arguments supported with install.3dm    *"
    echo "         *********************************************"
    echo "The following arguments are supported for use with the Install.3dm script."
    echo ""
    echo "-i or --i or install will install 3dm files and create needed configuration files."
    echo "*** Do not use -i or --i or install when using the 3ware rpm to install 3dm. ***"
    echo ""
    echo "-u or --u or uninstall will remove all 3dm components and configuration files."
    echo ""
    echo "-c or --c or confiure will run the configuration portion of the install script. It will create needed configuration files."
    echo "*** Use the --c or configure argument to configure 3dm or to reconfigure 3dm after using s 3ware rpm. ***"
    echo ""
    echo "*** Any other options will print this screen. ***"
    echo ""
    echo "Example (./install.3dm or ./install.3dm --i or ./install.3dm install) Will install 3dm files and create 3dmd.conf."
    echo "Example (./install.3dm --u or ./install.3dm uninstall) Will uninstall all 3dm components and configuration files."
    echo "Example (./install.3dm --c or ./install.3dm configure) Will run the configuration portion of the script to update/create 3dmd.conf."
    echo ""
    exit 1
    endif


## Check if rpm was used for installation.
#
if ($sw1 == "uninstall" || $sw1 == "install" || $sw1 == "configure") then
	if ($sw1 == "install" || $sw1 == "configure") then
	    if (-e /etc/3dmd.conf) then
    		echo ""
    		echo -n "An old 3dmd.conf file was found. Do you want to use the old one? (Y/N) [Y] "
    		set question = $<
	
    		if ($question == "y" || $question == "") then
        		set question = "Y"
			endif
    		endif
	endif

    echo ""
    echo "***************************************"
    echo "*** Important RPM related question. ***"
    echo "***************************************"
    echo "* Answer "N" if you are using the install.3dm script to install 3dm."
    echo "  If you answer "N" install.3dm will install all 3dm components."
    echo "* Answer "Y" if RPM was used for installing the driver/3dm software."
    echo "  3ware RPM packages install all 3dm components and only need to have"
    echo "  the configuration portion of this script run." 
    echo ""
    echo -n "Was RPM used to install the Escalade driver and/or 3dm? (Y/N) [N] "
    set rpm = $<

    ## Check for install/configure.
    #
    if ($sw1 == "install" || $sw1 == "configure") then
	if ($rpm == "Y" || $rpm == "YES" || $rpm == "Yes" || $rpm == "y" || $rpm == "yes") then
		set help = $default_help
		goto configure

	else

		## Figure out where we are
		#
	    	set install_dir = `pwd`

	    	## Upack 3dm files into /tmp so we can run this directly from the CD.
	    	#
	    	if (-e $install_dir/3dm-lnx.tgz) then
			if (-d /tmp/3ware) then
		    		rm -rf /tmp/3ware >& /dev/null
		    		endif

			mkdir -p /tmp/3ware
			tar zxfp 3dm-lnx.tgz -C /tmp/3ware
			cd /tmp/3ware

	    	else if (-e $install_dir/3dm-lnx.tar.gz) then
		     	if (-d /tmp/3ware) then
				 rm -rf /tmp/3ware >& /dev/null
			 	endif
		     	mkdir -p /tmp/3ware
		     	tar zxfp 3dm-lnx.tar.gz -C /tmp/3ware
		     	cd /tmp/3ware

	    	else
			echo ""
			echo "3dm-lnx.tgz installation file not in directory. Installation stopping."
			exit 1
			endif

		## Get 3DM version being installed.
		if (-e version.txt) then
			set newver = `cat version.txt | cut -d " " -f3`
			echo ""
			echo "**** 3DM version being installed is: $newver ****"
			echo ""
			endif

	    	## Check file location is correct.
	    	if (-d 3dm-lnx )then
			cd 3dm-lnx
			endif

		if ($question == "n" || $question == "N") then
	    		echo -n "Please enter the location of the help documentation. [$default_help] "
	    		set help = $<
	    		if ($help == "") then
				set help = $default_help
				endif
			endif
		goto install
		endif

    	else if ($sw1 == "uninstall") then
	     	goto uninstall
		endif
    	endif


uninstall:
if ($sw1 == "uninstall") then
    echo ""
    echo "######################################"
    echo "Checking for 3dm components to remove."
    echo "######################################"

    ps ax | grep '3dmd' | grep -v 'grep' >/dev/null
    if ($status == "0") then
	echo "**** Stopping 3dmd to allow uninstallation. ****"
	if (-e /etc/rc.d/3dm) then
	   /etc/rc.d/3dm stop

	   ## Clean up Symbolic links
	   echo -n "Removing 3dm Symbolic links... "
	   if ($distr == "redhat") then
		if (`uname -r` == "2.4.2-2" || `uname -r` == "2.4.2-2smp") then
			rm -f /etc/rc.d/rc?.d/*3w-xxxx >& /dev/null
			rm -f /etc/rc.d/rc?.d/*3dm >& /dev/null
		else
			chkconfig --del 3dm
			rm -f /etc/rc.d/rc?.d/*3w-xxxx >& /dev/null
			endif
	   else
	       rm -f /etc/rc.d/rc?.d/*3w-xxxx >& /dev/null
	       rm -f /etc/rc.d/rc?.d/*3dm >& /dev/null
	       endif

		
	   echo "done."
	   ## Remove 3dm init script.
	   echo -n "Removing /etc/rc.d/3dm... "
	   rm -f /etc/rc.d/3dm >& /dev/null
	   echo "done."

	else if (-e /etc/rc.d/init.d/3dm) then
	    	/etc/rc.d/init.d/3dm stop

		## Clean up Symbolic links
		echo -n "Removing 3dm Symbolic links... "
		if ($distr == "redhat") then
			if (`uname -r` == "2.4.2-2" || `uname -r` == "2.4.2-2smp") then
				rm -f /etc/rc.d/rc?.d/*3w-xxxx >& /dev/null
				rm -f /etc/rc.d/rc?.d/*3dm >& /dev/null
			else
				chkconfig --del 3dm
				rm -f /etc/rc.d/rc?.d/*3w-xxxx >& /dev/null
				endif
		else
		    rm -f /etc/rc.d/rc?.d/*3w-xxxx >& /dev/null
		    rm -f /etc/rc.d/rc?.d/*3dm >& /dev/null
		    endif

		echo "done."
		## Remove 3dm init script.
	    	echo -n "Removing /etc/rc.d/init.d/3dm... "
	   	rm -f /etc/rc.d/init.d/3dm >& /dev/null
	   	echo "done."
	    	endif
	endif

    if (-e /usr/local/bin/3dmpn) then
	echo -n "Removing /usr/local/bin/3dmpn... "
	rm -f /usr/local/bin/3dmpn >& /dev/null
	echo "done."
	endif


    if (-e /sbin/3dmd) then
	echo -n "Removing /sbin/3dmd... "
	rm -f /sbin/3dmd >& /dev/null
	echo "done."
	endif

    if (-e /usr/sbin/3dmd) then
	echo -n "Removing /usr/sbin/3dmd..."
	rm -f /usr/sbin/3dmd >& /dev/null
	echo "done."
	endif

    if (-e /etc/3dmd.conf) then
	set help = `cat /etc/3dmd.conf | grep HELP | cut -d ' ' -f2`
	echo -n "Removing 3dm help files... "
    	rm -rf $help >& /dev/null
	echo "done."
	echo ""
	echo -n "Do you want to remove the 3dmd.conf file? (Y/N) [Y] "
	set question2 = $<
	if ($question2 == "y" || $question2 == "") then
	    set question2 = "Y"
	    endif

	if ($question2 == "Y") then
		echo ""
		echo -n "Removing 3dm configuration files... "
	    	rm -f /etc/3dmd.conf* >& /dev/null
		echo "done."
		endif
	endif

echo "3dm removal complete."
endif


install:
## Check to see if install or configure argument was used with install.3dm
#
if ($sw1 == "install") then
    ## Check to see if 3dmd is running. If yes stop 3dmd
    #
    ps ax | grep 3dmd | grep -v grep >/dev/null
    if ($status == "0") then
        echo ""
	echo "**** Stopping 3dmd to load new configuration ****"
	if (-e /etc/init.d/3dm) then
	    /etc/init.d/3dm stop

	else if (-e /etc/rc.d/init.d/3dm) then
	    	 /etc/rc.d/init.d/3dm stop
		 endif
    	endif

    ## Unpack help files, setup help directory and move files to /usr/local/doc
    #
    if ($question == "Y") then
	set help = `cat /etc/3dmd.conf | grep HELP | cut -d ' ' -f2`
	endif

    if (-e 3dm-help.tgz) then
	if (-d $help) then
	    rm -rf $help >& /dev/null
	    endif
        mkdir -p $help
        tar zxf 3dm-help.tgz -C $help

    else if (-e 3dm-help.tar.gz) then
	    if (-d $help) then
		rm -rf $help >& /dev/null
		endif
	     mkdir -p $help
	     tar zxf 3dm-help.tar.gz -C $help

    else
	echo ""
	echo "3dm help files are missing. Installation stopping."
	exit 1
	endif

    ## Check if previous 3dmd is installed in old location.
    if (-e /sbin/3dmd) then
	rm -f /sbin/3dmd
	endif

    if (-e 3dmd) then
	/bin/cp -f 3dmd /usr/sbin
	chmod 755 /usr/sbin/3dmd

    else
	echo ""
	echo "3dm binary missing. Installation stopping."
	exit 1
	endif

    if ($question == "Y") then
	## Check for RemoteAccess setting in /etc/3dmd.conf
	cat /etc/3dmd.conf | grep -i 'REMOTEACCESS' > /dev/null
	if ($status == 0) then
	    set currentsetting = `cat /etc/3dmd.conf | grep -i 'REMOTEACCESS' | cut -d ' ' -f2` > /dev/null
	    if ($currentsetting == "Yes") then
		echo "3DM connection security is not set to limit connections to localhost only."
		echo -n "Do you want to change this setting to limit access to localhost only? (Y/N) [Y] "
		set newsetting = $<
		if ($newsetting == "Y" || $newsetting == "y" || $newsetting == "") then
		    cat /etc/3dmd.conf | sed -e s/'REMOTEACCESS Yes'/'REMOTEACCESS No'/ >>/etc/3dmd.conf
		    endif
		endif
	else
	    echo "3DM connection security is not currently setup on your system."
	    echo -n "Do you want to limit 3DM access to localhost only connections? (Y/N) [Y] "
	    set remoteaccess = $<
	    if ($remoteaccess == "Y" || $remoteaccess == "y" || $remoteaccess == "") then
		echo "REMOTEACCESS No" >>/etc/3dmd.conf

	    else
		echo "REMOTEACCESS Yes" >>/etc/3dmd.conf
		endif
	    endif   
 
	## Check for RO Password in /etc/3dmd.conf
	cat /etc/3dmd.conf | grep -i 'ROPASSWORD' > /dev/null
	if ($status != 0) then
		echo "ROPASSWORD No" >>/etc/3dmd.conf
		echo "ROKEY $default_passwd" >>/etc/3dmd.conf
		endif

	## Check for ExtLog path in /etc/3dmd.conf
	cat /etc/3dmd.conf | grep -i 'EXTLOG' > /dev/null
	if ($status != 0) then
		echo "EXTLOG $default_extlog" >>/etc/3dmd.conf
		endif

	goto finish	

    else 
	goto configure
	endif

    endif


howto:
if ($distr == "untested") then
    echo ""
    echo "******************************************************************************************"
    echo "**** Automatic configuration is only supported for the Red Hat and SuSE distributions. ***"
    echo ""
    echo "*** Note: 3ware tests and supports Red Hat and SuSE distributions only. ***"
    echo ""
    echo "You will need to configure the following manually on other systems."
    echo ""
    echo "You will need to create kill script links to init.d/3dm"
    echo "Kill scripts should be setup in all run levels that don't support full user functionality."
    echo "(example rc0.d, rc1.d, rc2.d, rc6.d, rcS.d)"
    echo ""
    echo "You will need to create start script links to init.d/3dm"
    echo "Start scripts should be setup in all run levels that support full user functionality."
    echo "(example rc3.d, rc4.d, rc5.d)"
    echo ""
    echo "If your release supports chkconfig you can use it as follows to setup the runlevel scripts."
    echo "chkconfig --add 3dm"
    echo "chkconfig --level 345 3dm on"
    echo ""
    echo "*** Note: To remove 3dm run level info use chkconfig --del 3dm ***"
    echo ""
    echo "Run level scripts are only provided for Red Hat and SuSE Linux."
    echo "You may need to make changes to enable them under other distributions."
    echo "cp -f 3w-xxxx.rc.* /etc/rc.d/init.d/3dm"
    echo "chmod 755  /etc/rc.d/init.d/3dm"
    echo ""
    echo "The 3dm binary was copied to /usr/sbin/3dmd"
    echo "3dmd.conf was created and placed in /etc"
    echo "******************************************************************************************"
    echo ""
    echo ""

    exit 0
    endif
endif


configure:

if ($sw1 == "install" || $sw1 == "configure" && $distr != "untested") then
    if ($question == "Y") then
	exit 0
	endif

	echo ""
    	echo -n "Would you like to have email notification enabled? (Y/N) [Y] "
    	set email = $<
	
    if ($email == "") then
	set email = "Y"
	endif

    if ($email == "Y" || $email == "y" || $email == "YES" || $email == "Yes" || $email == "yes") then
	echo -n "Please enter the name of your mail server. [$default_host]: "
	set mail_server = $<

	if ($mail_server == "") then
	    set mail_server = $default_host
	    endif

	echo -n "Please enter the name of the user you want sending email notification. [$default_sender]: "
	set mail_sender = $<

	if ($mail_sender == "") then
	    set mail_sender = $default_sender
	    endif

	echo -n "Please enter the name of the user you want receiving email notification. [$default_rcpt]: "
	set mail_rcpt = $<

	if ($mail_rcpt == "") then
	    set mail_rcpt = $default_rcpt
	    endif

    else
	set mail_server = $default_host
	set mail_sender = $default_sender
	set mail_rcpt = $default_rcpt
	endif

#    echo -n "Would you like to enable audio notification for application start and errors? (Y/N) [Y] "
#    set audio = $<
#    if ($audio == "") then
#	set audio = "Y"
#	endif

    echo -n "Please enter the port number you would like to use for web monitoring. [$default_port]: "
    set port = $<
    if ($port == "") then
	set port = $default_port
	endif

    ## Delete old backup file then move current file to backup before creating new .conf file.
    #
    if ( -e $file_name ) then
	rm -f $file_name.bak >& /dev/null
	mv -f $file_name $file_name.bak
	endif

    if ($email == "N" || $email == "n" || $email == "NO" || $email == "No" || $email == "no") then
	echo "EMAIL No"    >>  $file_name
	
    else
	echo "EMAIL Yes"   >>  $file_name
	endif

	echo "SERVER $mail_server" >> $file_name
	echo "SENDER $mail_sender" >> $file_name
	echo "RCPT $mail_rcpt"     >> $file_name

#    if ($audio == "N" || $audio == "n" || $audio == "NO" || $audio == "No" || $audio == "no") then
	echo "AUDIO No"    >> $file_name
	
#    else
#	echo "AUDIO Yes"   >> $file_name
#	endif

	echo "CALL3WARE No"            >> $file_name
	echo "PORT $port"              >> $file_name
	echo "FW $rebuild_rate"        >> $file_name
	echo "HELP $help"              >> $file_name
	echo "SNMP No"                 >> $file_name
	echo "PASSWORD No"             >> $file_name
	echo "KEY $default_passwd"     >> $file_name
	echo "ROPASSWORD No"           >> $file_name
	echo "ROKEY $default_passwd"   >> $file_name
	echo "EXTLOG $default_extlog"  >> $file_name
	
    echo -n "Would you like 3DM connection security to limit connections to localhost only? (Y/N) [Y] "
    set remoteaccess = $<
    if ($remoteaccess == "Y" || $remoteaccess == "y" || $remoteaccess == "") then
	echo "REMOTEACCESS No" >>/etc/3dmd.conf

    else
	echo "REMOTEACCESS Yes" >>/etc/3dmd.conf
	endif


finish:
if ($distr == "untested") then
    goto howto
    endif

    if ($distr == "redhat") then
	   ## Check for old script and remove it.
	if (-e /etc/rc.d/init.d/3w-xxxx) then
	    rm -f /etc/rc.d/init.d/3w-xxxx >& /dev/null
	    endif

	if (-e /etc/rc.d/init.d/3dm) then
	    rm -f /etc/rc.d/init.d/3dm >& /dev/null
	    endif

	if (-e 3w-xxxx.rc.$distr) then
	    /bin/cp -f 3w-xxxx.rc.$distr /etc/rc.d/init.d/3dm
	    chmod 755  /etc/rc.d/init.d/3dm
	    endif

	## Setup symbolic links for run levels.
	if (`uname -r` == "2.4.2-2" || `uname -r` == "2.4.2-2smp") then
    ## Setup symbolic links for run levels with old dir struct.
		    if (-d /etc/rc.d/rc0.d) then
			#rc0.d Halt
			ln -fs ../init.d/3dm /etc/rc.d/rc0.d/K603dm
			endif
		    if (-d /etc/rc.d/rc1.d) then
			#rc1.d Single user
			if (-e /etc/rc.d/rc1.d/S403dm) then
			    rm -f /etc/rc.d/rc1.d/S403dm
			    endif
			ln -fs ../init.d/3dm /etc/rc.d/rc1.d/K603dm
			endif
		    if (-d /etc/rc.d/rc2.d) then
			#rc2.d Multi-user without network
			if (-e /etc/rc.d/rc2.d/S403dm) then
			    rm -f /etc/rc.d/rc2.d/S403dm
			    endif
			ln -fs ../init.d/3dm /etc/rc.d/rc2.d/K603dm
			endif
		    if (-d /etc/rc.d/rc3.d) then
			#rc3.d Multi-user with network
			ln -fs ../init.d/3dm /etc/rc.d/rc3.d/S403dm
			endif
		    if (-d /etc/rc.d/rc4.d) then
			#rc4.d Multi-user with network
			ln -fs ../init.d/3dm /etc/rc.d/rc4.d/S403dm
			endif
		    if (-d /etc/rc.d/rc5.d) then
			#rc5.d Multi-user with network and X-windows
			ln -fs ../init.d/3dm /etc/rc.d/rc5.d/S403dm
			endif
		    if (-d /etc/rc.d/rc6.d) then
			#rc6.d reboot
			ln -fs ../init.d/3dm /etc/rc.d/rc6.d/K603dm
			endif
	else
		chkconfig --add 3dm
		chkconfig --level 345 3dm on
		endif

    else if ($distr == "suse") then
	    ## Check for old script and remove it.
	    if (-d /etc/rc.d/init.d) then
		if (-e /etc/rc.d/init.d/3w-xxxx) then
		    rm -f /etc/rc.d/init.d/3w-xxxx >& /dev/null
		    endif
		    
		if (-e /etc/rc.d/init.d/3dm) then
		    rm -f /etc/rc.d/init.d/3dm >& /dev/null
		    endif

		if (-e 3w-xxxx.rc.$distr) then
		    /bin/cp -f 3w-xxxx.rc.$distr /etc/rc.d/init.d/3dm
		    chmod 755  /etc/rc.d/init.d/3dm
		    endif


	    else if (-d /etc/init.d) then
    		if (-e /etc/init.d/3w-xxxx) then
		    rm -f /etc/init.d/3w-xxxx >& /dev/null
		    endif
		    
		if (-e /etc/init.d/3dm) then
		    rm -f /etc/init.d/3dm >& /dev/null
		    endif

		if (-e 3w-xxxx.rc.$distr) then
		    /bin/cp -f 3w-xxxx.rc.$distr /etc/init.d/3dm
		    chmod 755  /etc/init.d/3dm
		    endif
		endif

		    ## Setup symbolic links for run levels with old dir struct.
		    if (-d /etc/rc.d/rc0.d) then
			#rc0.d Halt
			ln -fs ../3dm /etc/rc.d/rc0.d/K603dm
			endif
		    if (-d /etc/rc.d/rcS.d) then
			#rcS.d Single user
			if (-e /etc/rc.d/rcS.d/S403dm) then
			    rm -f /etc/rc.d/rcS.d/S403dm
			    endif
			ln -fs ../3dm /etc/rc.d/rcS.d/K603dm
			endif
		    if (-d /etc/rc.d/rc1.d) then
			#rc1.d Single user
			if (-e /etc/rc.d/rc1.d/S403dm) then
			    rm -f /etc/rc.d/rc1.d/S403dm
			    endif
			ln -fs ../3dm /etc/rc.d/rc1.d/K603dm
			endif
		    if (-d /etc/rc.d/rc2.d) then
			#rc2.d Multi-user without network
			if (-e /etc/rc.d/rc2.d/S403dm) then
			    rm -f /etc/rc.d/rc2.d/S403dm
			    endif
			ln -fs ../3dm /etc/rc.d/rc2.d/K603dm
			endif
		    if (-d /etc/rc.d/rc3.d) then
			#rc3.d Multi-user with network
			ln -fs ../3dm /etc/rc.d/rc3.d/S403dm
			endif
		    if (-d /etc/rc.d/rc4.d) then
			#rc4.d Multi-user with network
			ln -fs ../3dm /etc/rc.d/rc4.d/S403dm
			endif
		    if (-d /etc/rc.d/rc5.d) then
			#rc5.d Multi-user with network and X-windows
			ln -fs ../3dm /etc/rc.d/rc5.d/S403dm
			endif
		    if (-d /etc/rc.d/rc6.d) then
			#rc6.d reboot
			ln -fs ../3dm /etc/rc.d/rc6.d/K603dm
			endif

    else
	echo ""
	echo "** Distribution not recognized **"
	echo ""
	echo "Manual configuration of runlevel scripts required."
	echo "The executable is '/usr/sbin/3dmd'."
	echo ""
	exit 0
	endif
    

    ## Start 3dmd.

    if (-e /etc/init.d/3dm) then
    	echo ""
    	echo "**** Starting 3dmd using configuration found in /etc/3dmd.conf ****"
    	/etc/init.d/3dm start

    else if (-e /etc/rc.d/init.d/3dm) then
	     echo ""
    	     echo "**** Starting 3dmd using configuration found in /etc/3dmd.conf ****"
	     /etc/rc.d/init.d/3dm start
	     endif

    ## Clean up files installation from 3ware.
    if (-e $file_name) then
	chmod 660 $file_name
	endif

    cd ..
    if (-d 3ware) then
        rm -rf 3ware >& /dev/null
	endif
endif
