# # First we'll get the customer name checking it's the correct # format etc. # AMER=explorer-database-americas@sun.com EMEA=explorer-database-emea@sun.com APAC=explorer-database-apac@sun.com CINFO=/etc/default/explorer EMAILTO="${AMER}" getField() { if [ -f $CINFO ]; then egrep "$1" $CINFO | cut -f2- -d":" | sed -e 's/^ //g' else echo "" fi } XCUSTOMER=`getField "Customer Name"` XCONTRACT=`getField "Contract ID"` XEMAILTO=`getField "Email results to"` XUSERNAME=`getField "User Name"` XUEMAIL=`getField "User e-mail"` XPHONE=`getField "User Phone"` XSERIAL=`getField "System Serial number"` XCUSTID=`getField "Customer ID"` XADDR1=`getField "Address line 1"` XADDR2=`getField "Address line 2"` XCITY=`getField "City"` XSTATE=`getField "State"` XCOUNTRY=`getField "Country"` XZIP=`getField "Zip Code"` CUSTNAME=xx echo "\n\nThis package requires a customer name to be entered." echo "This name must contain alphanumeric characters only." echo "Spaces in the name must be replaced by underscores," echo "e.g. Sun_Microsystems_Inc" echo " " while [ ! -z "$CUSTNAME" ]; do echo "Please enter your company name: [$XCUSTOMER] \c" read CUSTOMER if [ -z "$CUSTOMER" ]; then if [ -z "$XCUSTOMER" ]; then CUSTOMER="xx|" else CUSTOMER=$XCUSTOMER fi fi CUSTNAME=`echo ${CUSTOMER} | tr -d [:alnum:] | tr -d [--.] | tr -d [_]` [ ! -z "$CUSTNAME" ] && { echo "\nCompany name was NOT alphanumeric or contained spaces!"; } done # # Now we'll get the contract number, if none given, we'll use ? # echo "\n\nYou will now be prompted for customer specific information." echo "This information is optional, but Sun strongly recommends providing" echo "this information in its entirety. Accurate customer/contract information" echo "will allow Sun Proactive Support to provide more comprehensive and" echo "detailed reports.\n" echo "Please input this information when available, otherwise hit return.\n" echo "Please enter your contract number:[$XCONTRACT] \c" read CONTRACT [ -z "$CONTRACT" ] && { CONTRACT="$XCONTRACT"; } # # Check for previous install and add educated guess # if [ -f "${CINFO}" ] then DEFAULT=4 grep ${AMER} ${CINFO} >/dev/null 2>&1 if [ $? -eq 0 ] then DEFAULT=1 fi grep ${EMEA} ${CINFO} >/dev/null 2>&1 if [ $? -eq 0 ] then DEFAULT=2 fi grep ${APAC} ${CINFO} >/dev/null 2>&1 if [ $? -eq 0 ] then DEFAULT=3 fi else DEFAULT=1 fi # # Now we'll find out where the info is to be sent # echo " " echo "Choose the geography for emailing your results for analysis. The" echo "default is North / South America. You can use -myemail option to email" echo "the results to anywhere other than the 3 locations below:" echo " " echo "1. North / South America (${AMER})" echo "2. Europe, Middle East, Africa (${EMEA})" echo "3. Asia, Pacific (${APAC})" echo "4. None" echo " " echo "Where should the results be emailed [$DEFAULT]: \c" read ANSWER case "$ANSWER" in 1|Americas|americas|america|US|USA|usa|us) EMAILTO=${AMER} ;; 2|EMEA|emea|UK|uk|Europe|Africa) EMAILTO=${EMEA} ;; 3|APAC|apac|Asia|asia) EMAILTO=${APAC} ;; 4|NONE|none|None) EMAILTO= ;; "") case "${DEFAULT}" in 1) EMAILTO=${AMER} ;; 2) EMAILTO=${EMEA} ;; 3) EMAILTO=${APAC} ;; 4) EMAILTO= ;; *) # Shouldn't happen EMAILTO=${AMER} ;; esac ;; *) EMAILTO=${AMER} ;; esac # See if we have an optional address and no database entry echo $XEMAILTO | egrep explorer-database >/dev/null 2>&1 if [ $? -ne 0 ] then SECONDEMAIL=${XEMAILTO} else SECONDEMAIL=`echo $XEMAILTO|awk -F',' '{print $2;}'` fi if [ -z "$SECONDEMAIL" ]; then echo " " echo "Enter optional secondary email-address: \c" read SECONDEMAIL if [ ! -z "$SECONDEMAIL" ] then if [ ! -z "$EMAILTO" ]; then EMAILTO="$EMAILTO,$SECONDEMAIL" else EMAILTO="$SECONDEMAIL" fi fi else echo " " echo "You are currently sending email to $SECONDEMAIL" echo "If you no longer wish to send email to this address enter 'none'" echo " " echo "Enter optional secondary email-address: [$SECONDEMAIL] \c" read ans if [ -z "$ans" ]; then if [ ! -z "$EMAILTO" ]; then EMAILTO="$EMAILTO,$SECONDEMAIL" else EMAILTO="$SECONDEMAIL" fi else if [ "$ans" != "none" ]; then if [ ! -z "$EMAILTO" ]; then EMAILTO="$EMAILTO,$ans" else EMAILTO="$ans" fi fi fi fi # # Now we'll get the general info # echo " " echo "The following (optional) questions are used to identify" echo "your system. If an answer is not known just hit return." echo " " echo "Your name:[$XUSERNAME] \c" read USERNAME [ -z "$USERNAME" ] && { USERNAME="$XUSERNAME"; } echo "Your email address:[$XUEMAIL] \c" read UEMAIL [ -z "$UEMAIL" ] && { UEMAIL="$XUEMAIL"; } echo "Your phone number:[$XPHONE] \c" read PHONE [ -z "$PHONE" ] && { PHONE="$XPHONE"; } echo "Your System Serial number:[$XSERIAL] \c" read SERIAL [ -z "$SERIAL" ] && { SERIAL="$XSERIAL"; } echo "Your Customer ID number:[$XCUSTID] \c" read CUSTID [ -z "$CUSTID" ] && { CUSTID="$XCUSTID"; } echo "Your Address (line 1):[$XADDR1] \c" read ADDR1 [ -z "$ADDR1" ] && { ADDR1="$XADDR1"; } echo "Your Address (line 2):[$XADDR2] \c" read ADDR2 [ -z "$ADDR2" ] && { ADDR2="$XADDR2"; } echo "Your City:[$XCITY] \c" read CITY [ -z "$CITY" ] && { CITY="$XCITY"; } echo "Your State (eg. CA):[$XSTATE] \c" read STATE [ -z "$STATE" ] && { STATE="$XSTATE"; } echo "Your Country (eg. USA):[$XCOUNTRY] \c" read COUNTRY [ -z "$COUNTRY" ] && { COUNTRY="$XCOUNTRY"; } echo "Your Zip Code:[$XZIP] \c" read ZIP [ -z "$ZIP" ] && { ZIP="$XZIP"; } # # Now we'll see if we can run explorer now # echo " " if [ ! -z "${EMAILTO}" ] then echo "Do you wish to run explorer and mail the results to ${EMAILTO} \c" else echo "Do you wish to run explorer \c" fi echo "during this install[y/n]: \c" read ANSWER if [ "$ANSWER" = "y" -o "$ANSWER" = "Y" ]; then RUNNOW="Y" else RUNNOW="N" fi # # Now we'll see if we can run once a week? # echo " " echo "We recommend Sun Explorer is run once a week and the" echo "results emailed to the Sun Explorer database. If you" echo "agree with this, the root cron job will be modified." echo " " echo "Do you wish to run explorer once a week [y/n]: \c" read ANSWER if [ "$ANSWER" = "y" -o "$ANSWER" = "Y" ] then MODCRON="Y" echo " " CHOUR=24 while [ "$CHOUR" -lt 0 -o "$CHOUR" -gt 23 ]; do echo "At which hour would you like this to run (0 to 23) : \c" read CHOUR [ -z "$CHOUR" ] && { CHOUR=24; } done echo " " CMINUTE=60 while [ "$CMINUTE" -lt 0 -o "$CMINUTE" -gt 59 ]; do echo "At which minute would you like this to run (0 to 59) : \c" read CMINUTE [ -z "$CMINUTE" ] && { CMINUTE=60; } done echo " " CDAY=7 while [ "$CDAY" -lt 0 -o "$CDAY" -gt 6 ]; do echo "On which day would you like this to run (0-6 with 0=Sunday): \c" read CDAY [ -z "$CDAY" ] && { CDAY=7; } done else MODCRON="N" fi cat >$1 <