#!/bin/csh
echo " "
set requireSetupType="1"
if ($#argv > 0) then
	switch ($1)
		case "-notrap": 
			set requireSetupType="1"
			breaksw
		case "-ru": 
			set requireSetupType="1"
			breaksw
		default:
			set requireSetupType="0"
			breaksw
	endsw
endif
if ("$requireSetupType" == "1") then
echo " "
echo " "
echo "INTEL SOFTWARE LICENSE AGREEMENT"
echo "IMPORTANT - READ BEFORE COPYING, INSTALLING OR USING." 
echo " "
echo "Do not use or load this software and any associated materials (collectively," 
echo "the "Software") until you have carefully read the following terms and" 
echo "conditions. By loading or using the Software, you agree to the terms of this" 
echo "Agreement. If you do not wish to so agree, do not install or use the Software."
echo " "
echo "LICENSES: Please Note:"
echo "- If you are a network administrator, the "Site License" below shall apply to you."
echo "- If you are an end user, the "Single User License" shall apply to you."
echo "- If you are an original equipment manufacturer (OEM), the "OEM License" shall apply to you."
echo "- The Software may contain the software and other property of third party suppliers," 
echo "some of which may be identified in, and licensed in accordance with, an attached" 
echo ""third party license directory" or other similarly named text or file. In particular," 
echo "without limitation, this license does not apply to the open source components distributed" 
echo "with the Software. The corresponding open source licenses are attached to the open source" 
echo " components and are the only licenses that apply to the open source components."
echo " "
echo " "
echo "SITE LICENSE. You may copy the Software onto your organization's computers" 
echo "for your organization's use, and you may make a reasonable number of" 
echo "back-up copies of the Software, subject to these conditions:"
echo " "
echo " "
echo "1. This Software is licensed for use only in conjunction with Intel" 
echo "component products. Use of the Software in conjunction with non-Intel" 
echo "component products is not licensed hereunder." 
echo "2. You may not copy, modify, rent, sell, distribute or transfer any part" 
echo "of the Software except as provided in this Agreement, and you agree to" 
echo "prevent unauthorized copying of the Software."
echo "3. You may not reverse engineer, decompile, or disassemble the Software." 
echo "4. You may not sublicense or permit simultaneous use of the Software by" 
echo "more than one user."
echo "5. The Software may include portions offered on terms in addition to those"
echo "set out here, as set out in a license accompanying those portions." 
echo " "
echo " "
echo "SINGLE USER LICENSE. You may copy the Software onto a single computer for" 
echo "your personal, noncommercial use, and you may make one back-up copy of the"
echo "Software, subject to these conditions:"
echo " "
echo " "
echo "1. This Software is licensed for use only in conjunction with Intel" 
echo "component products. Use of the Software in conjunction with non-Intel"
echo "component products is not licensed hereunder." 
echo "2. You may not copy, modify, rent, sell, distribute or transfer any part" 
echo "of the Software except as provided in this Agreement, and you agree to" 
echo "prevent unauthorized copying of the Software."
echo "3. You may not reverse engineer, decompile, or disassemble the Software." 
echo "4. You may not sublicense or permit simultaneous use of the Software by" 
echo "more than one user."
echo "5. The Software may include portions offered on terms in addition to those"
echo "set out here, as set out in a license accompanying those portions." 
echo " "
echo " "
echo "OEM LICENSE: You may reproduce and distribute the Software only as an" 
echo "integral part of or incorporated in Your product or as a standalone" 
echo "Software maintenance update for existing end users of Your products," 
echo "excluding any other standalone products, subject to these conditions:"
echo " "
echo " "
echo "1. This Software is licensed for use only in conjunction with Intel"
echo "component products. Use of the Software in conjunction with non-Intel" 
echo "component products is not licensed hereunder."
echo "2. You may not copy, modify, rent, sell, distribute or transfer any part" 
echo "of the Software except as provided in this Agreement, and you agree to" 
echo "prevent unauthorized copying of the Software."
echo "3. You may not reverse engineer, decompile, or disassemble the Software." 
echo "4. You may only distribute the Software to your customers pursuant to a" 
echo "written license agreement. Such license agreement may be a "break-the-seal""
echo "license agreement. At a minimum such license shall safeguard" 
echo "Intel's ownership rights to the Software."
echo "5. The Software may include portions offered on terms in addition to those"
echo "set out here, as set out in a license accompanying those portions."
echo " "
echo " "
echo "NO OTHER RIGHTS. No rights or licenses are granted by Intel to You, expressly" 
echo "or by implication, with respect to any proprietary information or patent," 
echo "copyright, mask work, trademark, trade secret, or other intellectual property"
echo "right owned or controlled by Intel, except as expressly provided in this" 
echo "Agreement."
echo " "
echo " "
echo "OWNERSHIP OF SOFTWARE AND COPYRIGHTS. Title to all copies of the Software" 
echo "remains with Intel or its suppliers. The Software is copyrighted and" 
echo "protected by the laws of the United States and other countries, and" 
echo "international treaty provisions. You may not remove any copyright notices" 
echo "from the Software. Intel may make changes to the Software, or to items" 
echo "referenced therein, at any time without notice, but is not obligated to" 
echo "support or update the Software. Except as otherwise expressly provided, Intel"
echo "grants no express or implied right under Intel patents, copyrights," 
echo "trademarks, or other intellectual property rights. You may transfer the" 
echo "Software only if the recipient agrees to be fully bound by these terms and if" 
echo "you retain no copies of the Software."
echo " "
echo " "
echo "LIMITED MEDIA WARRANTY. If the Software has been delivered by Intel on" 
echo "physical media, Intel warrants the media to be free from material physical" 
echo "defects for a period of ninety days after delivery by Intel. If such a defect" 
echo "is found, return the media to Intel for replacement or alternate delivery of" 
echo "the Software as Intel may select."
echo " "
echo " "
echo "EXCLUSION OF OTHER WARRANTIES. EXCEPT AS PROVIDED ABOVE, THE SOFTWARE IS" 
echo "PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND" 
echo "INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A" 
echo "PARTICULAR PURPOSE. Intel does not warrant or assume responsibility for the" 
echo "accuracy or completeness of any information, text, graphics, links or other" 
echo "items contained within the Software."
echo " "
echo " "
echo "LIMITATION OF LIABILITY. IN NO EVENT SHALL INTEL OR ITS SUPPLIERS BE LIABLE" 
echo "FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, LOST PROFITS," 
echo "BUSINESS INTERRUPTION, OR LOST INFORMATION) ARISING OUT OF THE USE OF OR" 
echo "INABILITY TO USE THE SOFTWARE, EVEN IF INTEL HAS BEEN ADVISED OF THE" 
echo "POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS PROHIBIT EXCLUSION OR" 
echo "LIMITATION OF LIABILITY FOR IMPLIED WARRANTIES OR CONSEQUENTIAL OR INCIDENTAL" 
echo "DAMAGES, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU. YOU MAY ALSO HAVE" 
echo "OTHER LEGAL RIGHTS THAT VARY FROM JURISDICTION TO JURISDICTION." 
echo " "
echo " "
echo "TERMINATION OF THIS AGREEMENT. Intel may terminate this Agreement at any time"
echo "if you violate its terms. Upon termination, you will immediately destroy the" 
echo "Software or return all copies of the Software to Intel."
echo " "
echo " "
echo "APPLICABLE LAWS. Claims arising under this Agreement shall be governed by the"
echo "laws of California, excluding its principles of conflict of laws and the" 
echo "United Nations Convention on Contracts for the Sale of Goods. You may not" 
echo "export the Software in violation of applicable export laws and regulations." 
echo "Intel is not obligated under any other agreements unless they are in writing" 
echo "and signed by an authorized representative of Intel."
echo " "
echo " "
echo "GOVERNMENT RESTRICTED RIGHTS. The Software is provided with "RESTRICTED""
echo ""RIGHTS." Use, duplication, or disclosure by the Government is subject to" 
echo "restrictions as set forth in FAR52.227-14 and DFAR252.227-7013 et seq. or its"
echo "of Intel's proprietary rights therein. Contractor or Manufacturer is Intel"
echo "2200 Mission College Blvd., Santa Clara, CA 95052."
echo " "
echo " "
echo " "
echo -n Press Y to accept the License Agreement :
set EULA = $<
if ( "$EULA" != "y" && "$EULA" != "Y" ) then
  echo "EULA declined by User. Exiting installation..."
  exit(1);
endif
endif
set vivaldikeyvalue="2"
set eventnotificationchoice="1"
set firstArgDone="0"
set removepopup="0"
set removesnmp="0"
if ("$requireSetupType" == "1") then
#while(1)
clear
echo "Press 0 to exit from installation"
echo "Choose[1-5]:"
echo "            (1) - Complete"
echo "                  This option will install all program features."
echo "            (2) - Client"
echo "                  This option will only install components required to remotely view and" 
echo "                  configure servers."
echo "            (3) - StandAlone"
echo "                  This option will only install components required for local server management"
echo "            (4) - Local"
echo "                  This option will only install components required for local configuration"
echo "            (5) - Server"
echo "                  This option will only install components required for remote server management"
#echo "            (6) - upgrade only"
#echo "                  This option will only upgrade rwc2"
#echo "            (7) - upgrade only"
#echo "                  This option will only upgrade rwc2"
#echo "            (8) - upgrade only"
#echo "                  This option will only upgrade rwc2"
#echo "            (9) - upgrade only"
#echo "                  This option will only upgrade rwc2"
#echo "            (10) - upgrade only"
#echo "                  This option will only upgrade rwc2"
echo " "
echo "Note : Installer can also be run in a command line mode"
echo "Usage : install.sh [-option]"
echo "The options are :"
echo "              a"
echo "                The Complete Installation of RAID Web Console 2 (RWC2) "
echo "              c"
echo "                The Client components only program of RWC2"
echo "              s"
echo "               The StandAlone component of RWC2"
echo "              l"
echo "               The Local component of RWC2"
echo "              d"
echo "               The Server component of RWC2"
echo "              au"
echo "               The upgrade only option for Complete RWC2"
echo "              cu"
echo "               The upgrade only option for Client only RWC2"
echo "              su"
echo "               The upgrade only option for Standalone RWC2"
echo "              lu"
echo "               The upgrade only option for Local RWC2"
echo "              du"
echo "               The upgrade only option for Server RWC2"
echo -n Setup Type : 
set setuptype = $<
#if (0 <= $setuptype && $setuptype < 4) then
#	break;
#endif
#end

echo "Enter The SelfSigned Key Details :"
echo "          Enter 1 for 1024 key size"
echo "          Enter 2 for 2048 key size"
echo "          Both the MSM client and server need to have the same RSA key size enabled to be able to communicate with each other."
echo "          	- 2048 bit keys should be selected for more secure network communication"
echo "          	- 1024 bit keys should be used with MSM clients still using 1024 bit keys"
echo "          For more details please see the MSM software Users Guide."
echo "Enter the key size:(1 or 2) "
        set vivaldikeyvalue = $<
        if ( "$vivaldikeyvalue" != "1" && "$vivaldikeyvalue" != "2" ) then
                  echo "Invalid key size Selection..Exiting installation..."
                  exit 1;
        endif
echo "Below are choices where MSM behaviour works based on one of the selection by user, if MSM alert notification history files not found."
echo "For more details please see the MSM software Users Guide."
echo "Enter the Alert Notifications of Users Choice :(Default 1)"
echo "          Enter 1 for Last Reboot"
echo "          	MSM will be logged with events from last Reboot"
echo "          Enter 2 for Log Clear"
echo "          	MSM will be logged with events from last Log Clear"
echo "          Enter 3 for Last Shutdown"
echo "          	MSM will be logged with events from last Clean Shutdown"
echo "Enter the choice:(1 or 2 or 3) "
	set eventnotificationchoice = $<	
	if ( "$eventnotificationchoice" != "1" && "$eventnotificationchoice" != "2" && "$eventnotificationchoice" != "3" ) then
                  echo "Invalid Alert Notification Selection..Exiting installation..."
                  exit 1;
        endif		
		
switch($setuptype)
	case "1":
		echo -n "Starting complete installation of RAID Web Console 2 15.11.00-13"
		set setuptype="a"
		set upgradesetuptype="n"
		breaksw
	case "2":
		echo -n "Starting client installation of RAID Web Console 2 15.11.00-13"
		set setuptype="c"
		set upgradesetuptype="n"
		breaksw
	case "3":
		echo -n "Starting stand alone installation of RAID Web Console 2 15.11.00-13"
		set setuptype="s"
		set upgradesetuptype="n"
		breaksw
	case "4":
		echo -n "Starting Local installation of RAID Web Console 2 15.11.00-13"
		set setuptype="l"
		set upgradesetuptype="n"
		breaksw
	case "5":
		echo -n "Starting Server installation of RAID Web Console 2 15.11.00-13"
		set setuptype="d"
		set upgradesetuptype="n"
		breaksw
#   case "6":
#       echo -n "Starting upgrade only installation of RAID Web Console 2 13.04.03.01"
#       set setuptype="a"
#       set upgradesetuptype="u"
#       breaksw
#   case "7":
#       echo -n "Starting upgrade only installation of RAID Web Console 2 13.04.03.01"
#       set setuptype="c"
#       set upgradesetuptype="u"
#       breaksw
#   case "8":
#       echo -n "Starting upgrade only installation of RAID Web Console 2 13.04.03.01"
#       set setuptype="s"
#       set upgradesetuptype="u"
#       breaksw
#   case "9":
#       echo -n "Starting upgrade only installation of RAID Web Console 2 13.04.03.01"
#       set setuptype="l"
#       set upgradesetuptype="u"
#       breaksw
#   case "10":
#       echo -n "Starting upgrade only installation of RAID Web Console 2 13.04.03.01"
#       set setuptype="d"
#       set upgradesetuptype="u"
#       breaksw

	case "0":
		echo -n "Exiting Installation \n"
		exit
		breaksw
	default:
		echo "Incorrect option selected. Please retry....."
		echo "Choose[1-5]:"
		echo "            (1) - Complete"
		echo "                  This option will install all program features."
		echo "            (2) - Client"
		echo "                  This option will only install components required to remotely view and"
		echo "                  configure servers."
		echo "            (3) - StandAlone"
		echo "                  This option will only install components required for local server management"
		echo "            (4) - Local"
		echo "                  This option will only install components required for local configuration"
		echo "            (5) - Server"
		echo "                  This option will only install components required for remote server management"
#       echo "            (6) - Complete upgrade only"
#       echo "                  This option will only upgrade rwc2"
#       echo "            (7) - Client upgrade only"
#       echo "                  This option will only upgrade rwc2"
#       echo "            (8) - Standalone upgrade only"
#       echo "                  This option will only upgrade rwc2"
#       echo "            (9) - Local upgrade only"
#       echo "                  This option will only upgrade rwc2"
		exit	
		breaksw
endsw

else
switch($1)
	case "-a":
		set setuptype="1"
		set firstArgDone="1"
		set setuptype="a"
		set upgradesetuptype="n"
		breaksw
	case "-c":
		set setuptype="2"
		set firstArgDone="1"
		set setuptype="c"
		set upgradesetuptype="n"
		breaksw
	case "-s":
		set setuptype="3"
		set firstArgDone="1"
		set setuptype="s"
		set upgradesetuptype="n"
		breaksw
	case "-l":
		set setuptype="4"
		set firstArgDone="1"
		set setuptype="l"
		set upgradesetuptype="n"
		breaksw
	case "-d":
		set setuptype="5"
		set firstArgDone="1"
		set setuptype="d"
		set upgradesetuptype="n"
		breaksw
        case "-au":
                set setuptype="6"
                set firstArgDone="1"
                set setuptype="a"
                set upgradesetuptype="u"
                breaksw
        case "-cu":
                set setuptype="7"
                set firstArgDone="1"
                set setuptype="c"
                set upgradesetuptype="u"
                breaksw
        case "-su":
                set setuptype="8"
                set firstArgDone="1"
                set setuptype="s"
                set upgradesetuptype="u"
                breaksw
        case "-lu":
                set setuptype="9"
                set firstArgDone="1"
                set setuptype="l"
                set upgradesetuptype="u"
                breaksw
        case "-du":
                set setuptype="10"
                set firstArgDone="1"
                set setuptype="d"
                set upgradesetuptype="u"
                breaksw
    case "-notrap":
                breaksw
        default:
#                if ( $1 == "-notrap" ) then
#                        breaksw
#                endif
		echo "Incorrect option selected. Please retry....."
		echo "Usage : install.sh [-option]"
		echo "The options are :"
		echo "              a"
		echo "                The Complete Installation of RAID Web Console 2 (RWC2) "
		echo "              c"
		echo "                The Client components only program of RWC2"
		echo "              s"
		echo "               The StandAlone component of RWC2"
		echo "              l"
		echo "               The Local component of RWC2"
		echo "              d"
		echo "               The Server component of RWC2"
                echo "              au"
                echo "               The upgrade only option for Complete RWC2"
                echo "              cu"
                echo "               The upgrade only option for Client only RWC2"
                echo "              su"
                echo "               The upgrade only option for Standalone RWC2"
                echo "              lu"
                echo "               The upgrade only option for Local RWC2"
                echo "              du"
                echo "               The upgrade only option for Server RWC2"
		exit
endsw
endif

set firstArg="n"
set secondArg="n"
if ($firstArgDone == "1") then
	set firstArg=$2
	set secondArg=$3
else
	set firstArg=$1
	set secondArg=$2
endif
  switch($firstArg)
	case "-ru":
		switch ($secondArg)
			case "popup":
				set removepopup="1"
				echo -n " without popup"
				breaksw
			case "snmp":
				set removesnmp="1"
				echo -n " without snmp"
				breaksw
			case "popup,snmp":
				set removepopup="1"
				set removesnmp="1"
				echo -n " without popup,snmp"
				breaksw
			case "snmp,popup":
				set removepopup="1"
				set removesnmp="1"
				echo -n " without popup,snmp"
				breaksw
		endsw
		breaksw
   endsw
endif

echo "...."

set TRAPIND="Y"

if ( "$1" == "-notrap" ) then
        set TRAPIND="N"
endif
if ( "$2" == "-notrap" ) then
        set TRAPIND="N"
endif
if ( "$3" == "-notrap" ) then
        set TRAPIND="N"
endif
if ( "$4" == "-notrap" ) then
        set TRAPIND="N"
endif

#echo $setuptype
#echo $vivaldikeyvalue

setenv setuptype $setuptype
setenv upgradesetuptype $upgradesetuptype
setenv removepopup $removepopup
setenv removesnmp $removesnmp
setenv TRAPIND $TRAPIND
setenv vivaldikeyvalue $vivaldikeyvalue
setenv eventnotificationchoice $eventnotificationchoice
./RunRPM.sh
