#! /bin/sh # # $Id: nmc_request.SunOS,v 1.6.2.1 2007/01/22 20:08:04 tompkb1 Exp $ Copyright (c) 1999-2006 EMC Corporation. # # # Copyright (c) 1999-2006 EMC Corporation. # # All rights reserved. This is an UNPUBLISHED work, and # comprises proprietary and confidential information of EMC. # Unauthorized use, disclosure, and distribution are strictly # prohibited. Use, duplication, or disclosure of the software # and documentation by the U.S. Government is subject to # restrictions set forth in a license agreement between the # Government and EMC or other written agreement specifying # the Government's rights to use the software and any applicable # FAR provisions, such as FAR 52.227-19. # # # Function: # page_break # # Description: # Waits for the RETURN key to be pressed # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # # Notes: page_break() { echo echo "PRESS RETURN TO CONTINUE" read x } # # Function: # setecho # # Description: # Defines the echo_n() function with proper echo semantics. # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # # Notes: # setecho() { umask 22 if [ -f /usr/ucb/echo ]; then echo_n() { echo -n "$*" } else echo_n() { echo "$* \c" } fi } # # Function: # copyright # # Description: # Prints an EMC copyright notice. # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # $1 Name of product. # # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # # Notes: # # The VERSION variable is set in the pkginfo(4) file. # copyright() { cat < /dev/null 2>&1 if [ $? -ne 0 ]; then echo echo "ERROR: ${result} is not a valid port number!" continue fi if [ $result -lt 1024 -o $result -gt 49151 ]; then echo echo "ERROR: Valid port range is between 1024 and 49151" continue fi if [ $result -eq 2638 ]; then echo echo "ERROR: Port 2638 is reserved for database server" continue fi if [ $result -eq 9002 ]; then echo echo "ERROR: Port 9002 is the preferred port for EMC Backup Advisor product" continue fi if [ $usedok -eq 0 ]; then inuse=`netstat -na|grep -w "LISTEN"|grep -w "${result}"` if [ ! -z "${inuse}" ]; then echo echo "WARNING: Port ${result} is already in use." port=$result yesno "Do you wish to specify a different port number" y if [ "$result" = "n" ] ; then result=$port break fi else break fi fi done # result is set from ask() } # # Function: # mntsize # # Description: # Prints a listing of local filesystems and their sizes. # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # result The largest local filesystem. # # Notes: # mntsize() { echo echo "List of local filesystems and available space:" echo tmpfile="/tmp/${PKG}fstmp$$" rm -f "$tmpfile" df -k 2>/dev/null | sort -nr +3 -5 | \ awk '/^\/dev/ { if ( $6 != "/tmp" && $6 != "/dev/fd" ) \ printf("%s %s\n", $6, $4) }' > "$tmpfile" cat "$tmpfile" | while read mnt size ; do printf "%-30s:%8.8s\n" $mnt $size done result=`head -1 "$tmpfile" | awk '{print $1}'` rm -f "$tmpfile" } # # Function: # setparam # # Description: # Writes a parameter to the response file. # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # $1 The variable name to set. # $2 The value of the variable. # # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # # Notes: # setparam() { echo "${1}=${2}" >> "$REQUEST" } # # Function: # gstpid # # Description: # Checks if a gstd instance exists and returns its pid. # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # result The pid of a gstd instance, or nil. # # Notes: # gstpid() { result=`/usr/bin/ps -e | awk '$4~/^gstd$/{print $1}'` } # # Function: # is_ascii_path # # Description: # Checks if the specified path is ascii # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # test_path path to check # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # result y or n # # Notes: # is_ascii_path() { test_path=$1 # empty out all acceptable characters result_temp_path=`echo $test_path | sed 's?[a-zA-Z0-9\^\?_/\$&:!,\.\(\)\*=~# @\+%-]??g'` # Check if there are any characters still present if [ "X$result_temp_path" != "X" ]; then result=n else result=y fi } # # Function: # checkforupgrade # # Description: # Checks presence of old config file and reads its values # # Arguments: # # Parameter Purpose # ---------------------- -------------------------------------------- # # Returns: # # Return Variable Purpose # ---------------------- -------------------------------------------- # # Notes: # checkforupgrade() { # Check if an old config file is present if [ -f $BASEDIR/etc/.gstd.conf* ]; then OLDCONF=`ls -lt $BASEDIR/etc/.gstd.conf* | awk 'NR == 1 { print $NF }'` # Get the version of the old Console installation # Get the last component of the file name OLDCONFVER=`echo $OLDCONF | awk -F/ 'NR == 1 { print $NF }'` #Get the version OLDCONFVER=`echo $OLDCONFVER | cut -d "." -f 4,5 | sed 's?[^0-9]??g'` if [ -f "$OLDCONF" ]; then echo echo "NOTE" echo "====" echo "Install has detected the configuration file of a previous ${PKG}" echo "package. Install will attempt to read the configuration parameters" echo "in this file and present them as default values where appropriate." echo "Please modify any value that is incorrect or needs to be changed." echo DEFAULT_BASEPORT=`cat "$OLDCONF" | awk '/http_svc_port/ { print substr($4,1,length($4)-1) }'` DEFAULT_GSTPORT=`cat "$OLDCONF" | awk '/clnt_svc_port/ { print substr($4,1,length($4)-1) }'` # For database pathname take care of situation where pathname has spaces DEFAULT_DBDIR=`cat "$OLDCONF" | awk '/current_db_dir/ { DBNM = $4 i = 5 while ( i <= NF ) { DBNM = DBNM " " $i ++i } } END { print substr(DBNM,2,length(DBNM)-3) }'` if [ ! -f "$DEFAULT_DBDIR/$DBNAME" ]; then DEFAULT_DBDIR= fi # For jre_location take care of situation where pathname has spaces DEFAULT_JRELOC=`cat "$OLDCONF" | awk '/jre_location/ { JRELOC = $4 i = 5 while ( i <= NF ) { JRELOC = JRELOC " " $i ++i } } END { print substr(JRELOC,2,length(JRELOC)-3) }'` if [ ! -f "$DEFAULT_JRELOC/bin/java" ]; then DEFAULT_JRELOC= fi setparam LGTO_OLDCONF "$OLDCONF" fi fi } # # main # # NOTE: some systems put "Berkeley" utilities in /usr/ucb, others (e.g. SGI) # put them in /usr/bsd. Also, some systems use /usr/etc and other use # /usr/sbin. We include all variants in addition to the path to this # program to be safe. mypath="`expr X\"${1}\" : X'\(.*\)/.*' \| X\"${1}\" : X'\(/\)[^/]*$' \| 'X'`" PATH=/usr/ucb:/usr/bsd:/bin:/usr/bin:/etc:/usr/etc:/usr/sbin:$mypath:$PATH export PATH REQUEST=$1 DBNAME=lgto_gst.db DBLOG=lgto_gst.log if [ "${PKG}" = "LGTOnmc" ]; then BRAND="NetWorker Management Console" BASEBRAND="NetWorker" DEFAULT_NSRDIR="/usr/sbin" else BRAND="Sun StorageTek EBS" BASEBRAND="Sun StorageTek EBS" DEFAULT_NSRDIR="/usr/sbin/nsr" fi # setup proper echo_n setecho # print copyright banner copyright "Base GST Server" # get package dir BASEDIR="/opt/${PKG}" mntsize if [ "X$result" = "X/" ]; then TEMP_DEFAULT_DBDIR="/lgto_gstdb" else TEMP_DEFAULT_DBDIR="${result}/lgto_gstdb" fi # Get the base directory while true; do ask "What directory should the $PKGINST package be installed in" "$BASEDIR" BASEDIR="$result" is_ascii_path "$BASEDIR" if [ "$result" = "n" ]; then echo echo "ERROR: The path contains invalid characters: $result_temp_path" BASEDIR="/opt" else break fi done # Don't enforce the presence of the base directory in request # script. pkgadd will anyway give the choice to create BASEDIR # if it does not exist before install begins. checkforupgrade # Check for JRE echo echo "The Command Line Reports feature of this product" echo "requires a Java Runtime Environment (JRE) be" echo "installed on this machine. The JRE version should be" echo "1.4.2 or higher, up to (but not including) 1.6." yesno "Is there a supported JRE already installed on this machine" y if [ "$result" = "n" ]; then echo echo "In order to enable the Command Line Reports feature, a JRE is" echo "required. A self-extracting image of JRE 1.5.0 is available" echo "in the $BRAND distribution for" echo "your convenience. Please note that if this package is installed" echo "without the JRE, you will have to uninstall and reinstall this" echo "package to enable the Command Line Reports feature later." yesno "Do you want to stop the install of this package and install JRE first" y if [ "$result" = "y" ]; then echo echo "Install terminating on user request." echo exit 1 fi askjre=0 else askjre=1 fi while [ $askjre -eq 1 ]; do ask "Please specify the directory where JRE is installed" "$DEFAULT_JRELOC" if [ -z "$result" ]; then continue fi LGTO_JRELOC="$result" is_ascii_path "$LGTO_JRELOC" if [ "$result" = "n" ]; then echo echo "ERROR: The path contains invalid characters: $result_temp_path" else # Get the version. if [ -x "$LGTO_JRELOC/bin/java" ]; then JAVA_VERSION=`"$LGTO_JRELOC/bin/java" -version 2>&1 | awk ' /java version/ { print $3 }' | sed 's/[^0-9]//g'` # Ensure the version is 6 digits long JAVA_VERSION=`echo "$JAVA_VERSION"000000` JAVA_VERSION=`echo $JAVA_VERSION | cut -c1-6` if [ $JAVA_VERSION -lt 142000 -o $JAVA_VERSION -gt 159999 ]; then echo echo "ERROR" echo "-----" echo "The version of JRE is not within the required range," echo "which is 1.4.2 or higher but less than 1.6. Please" echo "install the correct version of JRE before installing" echo "this package." echo exit 1 else setparam LGTO_JRELOC "$LGTO_JRELOC" break fi else echo echo "ERROR: Could not locate executable file: $LGTO_JRELOC/bin/java" continue fi fi done # get embedded web server port # Set default value if not set already if [ "X$DEFAULT_BASEPORT" = "X" ]; then DEFAULT_BASEPORT=9000 fi validport "What port should the web server use" $DEFAULT_BASEPORT 0 httpport=$result setparam LGTO_HTTPPORT "$httpport" # get GST server port # Set default value if not set already if [ "X$DEFAULT_GSTPORT" = "X" ]; then DEFAULT_GSTPORT=`expr $httpport + 1` # Make sure default port is in valid range if [ $DEFAULT_GSTPORT -gt 49151 ]; then DEFAULT_GSTPORT=9001 fi # Do not use EMC Backup Advisor port if [ $DEFAULT_GSTPORT -eq 9002 ]; then DEFAULT_GSTPORT=9003 fi fi while true; do validport "What port should the GST server use" $DEFAULT_GSTPORT 0 if [ $result -eq $httpport ]; then echo echo "ERROR: Web server and GST server port numbers cannot be the same" else setparam LGTO_GSTPORT "$result" break fi done # get database dir # Set default value if not set already if [ "X$DEFAULT_DBDIR" = "X" ]; then DEFAULT_DBDIR=$TEMP_DEFAULT_DBDIR fi while true ; do ask "What directory should be used for the ${PKG} database" "$DEFAULT_DBDIR" datadir="$result" is_ascii_path "$datadir" if [ "$result" = "n" ]; then echo echo "ERROR: The path contains invalid characters: $result_temp_path" continue fi if [ -f "$datadir/$DBNAME" ]; then yesno "$datadir/$DBNAME already exists, do you want to retain this database" y if [ "$result" = "y" ]; then setparam LGTO_OVERWRITE N LGTO_OVERWRITE="N" break fi fi parent=`dirname "$datadir"` if [ -d "$parent" ] ; then # check if database exists if [ -f "$datadir/$DBNAME" ] ; then yesno "$datadir/$DBNAME already exists, is it okay to remove it" n if [ "$result" = "y" ] ; then # We will remove the log file also if present setparam LGTO_OVERWRITE Y break fi elif [ -f "$datadir/$DBLOG" ] ; then # For some reason, if only the log file is present - remove it yesno "$datadir/$DBLOG already exists, is it okay to remove it" n if [ "$result" = "y" ] ; then setparam LGTO_OVERWRITE Y break fi else break fi else yesno "Parent directory $parent does not exist, should it be created" y if [ "$result" = "y" ] ; then break fi fi done setparam LGTO_DATADIR "$datadir" # get NetWorker directory while true ; do validdir "Where are the $BASEBRAND binaries installed" "$DEFAULT_NSRDIR" if [ -f "${result}/nsrexecd" ] ; then break else echo echo "ERROR: nsrexecd(1m) is not present in ${result}! Please re-enter." fi done setparam LGTO_NSRDIR "$result" # find any existing processes gstpid pid=$result if [ -n "$pid" ]; then yesno "A GST server appears to be running. Should it be terminated" y if [ "$result" = "y" ] ; then setparam LGTO_STOPPID $pid fi fi yesno "Start daemons at end of installation" n setparam LGTO_KEEPBOOT "$result" # Write BASEDIR to environment setparam BASEDIR "$BASEDIR" exit 0