DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦c9fb66842⟧ TextFile

    Length: 42710 (0xa6d6)
    Types: TextFile
    Names: »do_get_license_info«

Derivation

└─⟦1e97d88e5⟧ Bits:30000533 8mm tape, Rational 1000, RATIONAL ASIS (AIX) 110.2.4.15
    └─⟦this⟧ »./releases/asis.110.2.4.15/install/do_get_license_info« 

TextFile

#!/bin/sh
# @(#)do_get_license_info  $Revision: 1.22 $  $Date: 1994/01/17 17:44:46 $
# @(#)Copyright(c) 1993,1994 by Rational.
#
#  MODULE SPECIFICATION
#  Name:
#    do_get_license_info
#
#  Subsystem:
#    install
#
#  Description:
#    Query the user for the information that Rational
#    Customer will need to supply a license file password.
#    This script depends on a file called .${feature}_version that is
#    installed in the root of the $def_home tree.  The file is used to get
#    the default version of the feature to license.
#

def_home=`dirname $install_dir`

put_var GET_LICENSE_INFO STARTED

check_and_set_arch

read_prod_desc

if [ -s $install_dir/.install_defaults ]
then
    . $install_dir/.install_defaults
elif [ -s $install_dir/.install_defaults.sav ]
then
    mv $install_dir/.install_defaults.sav $install_dir/.install_defaults
    . $install_dir/.install_defaults
else
    fatal "Could not find $install_dir/.install_defaults file.
           Have you run the install yet?"
fi


#------------------------------------------------------------------------
verbose() {
#------------------------------------------------------------------------
#
# If verbose mode, echo args.
#

    if [ $SV_VERBOSE_MODE = yes ]
    then
        if [ "$1" = '-i' ]
        then
            # Indent
            echo -n "    "
            shift
        fi
        fmt_mesg "$*"
    fi
}


#------------------------------------------------------------------------
is_lic_file() {
#------------------------------------------------------------------------
#
# Search a license file to verify that it is indeed a license file.
# Look for lines beginning with 'SERVER' and 'DAEMON' just to make sure.
#

    rc=$TRUE

    if [ -z "$1" ]
    then
        return $FALSE
    fi

    if [ ! -f "$1" ]
    then
        fmt_mesg "Warning - License file '$1' does not exist"
        return $FALSE
    fi


    if grep '^SERVER' $1 >/dev/null
    then
        :
    else
        echo "Warning - No server line(s) in license file."
        rc=$FALSE
    fi

    if grep '^DAEMON' $1 >/dev/null
    then
        :
    else
        echo "Warning - No daemon line(s) in license file."
        rc=$FALSE
    fi

    if [ $rc = $FALSE ]
    then
        fmt_mesg "$1 does not appear to be a license file."
    fi
    return $rc
}

#------------------------------------------------------------------------
verify_server() {
#------------------------------------------------------------------------
#
# Function to verify that a hostname is valid and that it appears
# to be running UNIX, and can get at the lmhostid program.
#
# globals: SERVER
#
# Set HOSTID and PORT.
#

    ipaddr=
    if [ $SERVER = "$HOSTNAME" ]
    then
        verbose "No remote verification needed. $SERVER is the local host"
        $LICENSE_DIR/lmhostid |
            sed -n -e '2s/.*"\([^"]*\)".*/\1/p' > /tmp/hostid.$$
        add_cleanup_file /tmp/hostid.$$
        def_hostid=`cat /tmp/hostid.$$`
        /bin/rm -f /tmp/hostid.$$

        if [ -z "$def_hostid" ]
        then
            fmt_mesg "Can't run $LICENSE_DIR/lmhostid.
                Possible installation failure.
                Check installation and try again."
            exit 1
        fi
    else
        if [ -n "`domainname`" ]
        then
            echo -n "Checking NIS hosts map for $SERVER ... "
            ipaddr=`ypmatch $SERVER hosts 2>/dev/null | awk '{print $1}'`
            if [ -z "$ipaddr" ]
            then
                echo Not Found.
            else
                echo Found it.
            fi
        fi

        if [ -z "$ipaddr" ]
        then
            echo -n "Checking for $SERVER in /etc/hosts ... "
            ipaddr=`grep -w $SERVER /etc/hosts | awk '{print $1}'`
            if [ -z "$ipaddr" ]
            then
                echo Not Found.
            else
                echo Found it.
            fi
        fi

        badhost=no
        if [ -z "$ipaddr" ]
        then
            echo "Cannot find $SERVER in NIS map or /etc/hosts."
            badhost=yes
        else
            if [ $SV_VERIFY_WITH_RSH = yes ]
            then
                while true
                do
                    get_input "Input $BASE_VAR on $SERVER" $PROD_HOME
                    REM_HOME=$result
                    if [ $feature = rose ]
                    then
                        REM_HOSTID=$REM_HOME/license/$rem_arch/lmhostid
                    else
                        REM_HOSTID=$REM_HOME/$rem_arch/cots/license/lmhostid
                    fi

                    echo -n "Getting license manager hostid (via RSH): Wait ... "
                    rsh $SERVER $REM_HOSTID 2> /tmp/err.$$ |
                        sed -n -e '2s/.*\"\([^\"]*\)\".*/\1/p' \
                        >  /tmp/hostid.$$

                    def_hostid=`cat /tmp/hostid.$$`
                    /bin/rm -f /tmp/hostid.$$
                    if [ -n "$def_hostid" ]
                    then
                        echo "got it. ($def_hostid)"
                        break
                    else
                        echo error.
                        fmt_mesg "Can't verify license manager hostid of
                            $SERVER.  The error message returned was:"
                        cat /tmp/err.$$
                        echo
                        echo "This may be because of one of the following:"
                        echo
                        echo "  1) The host ($SERVER) or the network to the host is down."
                        echo
                        echo "  2) You do not have permission to initiate a remote-shell to $SERVER."
                        echo
                        echo "  3) $SERVER does not have access to $BASE_VAR ($PROD_HOME)."
                        echo
                        get_yn "Do you wish to try to contact $SERVER again?" yes
                        if [ $result = no ]
                        then
                            badhost=yes
                            break
                        fi
                    fi
                done
            fi
        fi

        if [ $badhost = yes ]
        then
            get_yn "Is $SERVER a valid host?" no
            if [ $result = no ]
            then
                return $FALSE
            fi
        fi
    fi

    while true
    do
        get_input "Enter license manager hostid of $SERVER, in hex:" $def_hostid
        if [ -n "$result" ]
        then
            HOSTID=$result
            break
        else
            fmt_mesg "The license manager hostid of $SERVER may be obtained by
                running the program 'lmhostid' on $SERVER.  The lmhostid
                program can be found in the directory: $LICENSE_DIR"
        fi
    done

    if [ "$SV_NODE_LOCKED" = yes ]
    then
        SV_NL_HOSTID=$HOSTID
        save_vars
    else
        SV_NL_HOSTID=
        SV_NL_HOSTID=
        SV_DISPLAY=
        save_vars
    fi

    if [ -z "$def_port" ]
    then
        def_port=$def_lic_port
    fi

    get_input "Enter TCP/IP port number for server:"  $def_port
    PORT=$result

    return $TRUE
}

#------------------------------------------------------------------------
get_server() {
#------------------------------------------------------------------------
#
# Search for server number (arg 1) out of file $SV_LIC_FILE_NAME.
# Sets def_server, def_hostid, and def_port.
#

    def_server=$HOSTNAME
    def_hostid=
    def_port=$def_lic_port

    if [ -f "$SV_LIC_FILE_NAME" ]
    then
        if grep "^SERVER" $SV_LIC_FILE_NAME >/dev/null
        then
            set -- `grep "^SERVER" $SV_LIC_FILE_NAME | head -$1 | tail -1`
            def_server=$2
            def_hostid=$3
            def_port=$4
        fi
    fi
}

#------------------------------------------------------------------------
dump_servers() {
#------------------------------------------------------------------------
#
# Go through the license file in $1 pulling out servers
#

    echo
    if [ -s "$SV_LIC_FILE_NAME" ]
    then
        if grep "^SERVER " $SV_LIC_FILE_NAME >/dev/null
        then
            grep "^SERVER " $SV_LIC_FILE_NAME |
            awk '{printf("    %s) License Server: %-16s  Hostid: %-10s  Port: %-5s\n", NR, $2, $3, $4)}'
        fi
    fi
    echo
}

#------------------------------------------------------------------------
find_license_files() {
#------------------------------------------------------------------------
#
# Build a list of possible license files in /tmp/lic_files.$$
#

    add_cleanup_file /tmp/lic_files.$$ /tmp/lic_list.$$

    verbose "Creating a list of possible license files."
    echo $APEX_LIC_FILE_NAME > /tmp/lic_list.$$
    echo /usr/local/flexlm/licenses/license.dat >> /tmp/lic_list.$$
    echo $SV_LIC_FILE_NAME >> /tmp/lic_list.$$
    echo $DEF_LIC_FILE_NAME >> /tmp/lic_list.$$

    if [ $USE_LIC_FILE = yes ]
    then
        # Search the LM_LICENSE_FILE env. var. for our daemon/feature lines.
        echo "Now searching for valid license files."
        if [ -n "$LM_LICENSE_FILE" ]
        then
            for lic_file in `echo $LM_LICENSE_FILE | sed -e 's/:/ /g'`
            do
                echo $lic_file
            done >> /tmp/lic_list.$$
        fi
    fi

    # Create a list of unique file names.  Verify files if user wants
    # to use an existing file.
    for file in `cat /tmp/lic_list.$$ | sort -u`
    do
        if [ $USE_LIC_FILE = no ]
        then
            if [ ! -f $file ]
            then
                echo $file
            fi
        elif is_lic_file $file > /dev/null
        then
            echo $file
        fi
    done > /tmp/lic_files.$$

    if [ $USE_LIC_FILE = yes ]
    then
        case `cat /tmp/lic_files.$$ | wc -l` in
            0 )
                ;;
            1 )
                echo
                echo "The following license file was found:"
                sed -e "s/^/    /g" /tmp/lic_files.$$
                ;;
            * )
                echo
                echo "The following license files have been found:"
                sed -e "s/^/    /g" /tmp/lic_files.$$
                ;;
        esac
    fi
}

#------------------------------------------------------------------------
verify_lic_file_name() {
#------------------------------------------------------------------------
#
# Verify a license file exists and is writable.
#

    if [ $USE_LIC_FILE = yes ]
    then
        if [ ! -f "$filename" ]
        then
            fmt_mesg "$filename does not exist.
                You must enter the name of a valid license file."
            filename=
            return $FALSE
        else
            is_lic_file $filename
            if [ $? -eq $FALSE ]
            then
                filename=
                return $FALSE
            fi

            if [ ! -w "$filename" ]
            then
                fmt_mesg "$filename exists, but is not writable.
                    You must enter the name of a file which is writable."
                filename=
                return $FALSE
            fi
        fi
    else
        if [ -f "$filename" ]
        then
            fmt_mesg "$filename exists.
                You must enter the name of a file which does not exist."
            filename=
            return $FALSE
        fi

        if touch $filename 2>/dev/null
        then
            /bin/rm -f $filename
        else
            fmt_mesg "Cannot create $filename. The directory
                `dirname $filename` must exist and you need to
                have write permissions for it.  Otherwise,
                you must select a license file which can be created."
            filename=
            return $FALSE
        fi

    fi
    return $TRUE
}

#------------------------------------------------------------------------
get_lic_file_name() {
#------------------------------------------------------------------------
#
# Input the path name of the license file
#

    get_input "Input pathname of license file to use:"
    if [ -n "$result" ]
    then
        filename=$result
        verify_lic_file_name
    fi
}

#------------------------------------------------------------------------
select_license_file() {
#------------------------------------------------------------------------
#
# Select a license file.  Set SV_LIC_FILE_NAME
#

    #separator
    if [ ! -f /tmp/lic_files.$$ ]
    then
        if [ $USE_LIC_FILE = no ]
        then
            fatal No license file choices for new license file. \
                  Please report this bug to $vendor.
        fi

        verbose "This script was not able to find a license file in any of
            the standard locations to use as the license file for the
            SERVER and DAEMON lines."

        verbose "You will need to enter the filename of an existing license
            file so that this script can get the required information."

        verbose "If you got to this prompt by mistake, you can press
            Control-C to break from this script and try again."

        filename=
        while [ -z "$filename" ]
        do
            get_lic_file_name
        done

        SV_LIC_FILE_NAME=$filename
        save_vars
    else
        nlines=`wc -l /tmp/lic_files.$$ | awk '{print $1}'`
        verbose "Here, you are presented with a list of filenames that are
            typically used for the license file location.  You can
            select one of the files from the list, or enter a filename
            not in the list by selecting '0' at the prompt."

        # Now present the list of license files. '0' is special; it allows
        # the input of another filename (which gets set into SV_LIC_FILE_NAME.

        echo
        echo "Select a file from the list of potential license files."
        echo "Enter 0 to enter file name directly."
        echo
        echo "      0 - Enter a file name not in this list"
        num=1
        def_file_num=1
        for lic_file in `cat /tmp/lic_files.$$`
        do
            if [ "$lic_file" = "$DEF_LIC_FILE_NAME" ]
            then
                def_file_num=$num
                echo ">>>>> $num - $lic_file"
            else
                echo "      $num - $lic_file"
            fi
            num=`expr $num + 1`
        done

        while true
        do
            get_input "Enter file number (0 to $nlines):" $def_file_num
            file_num=$result
            if [ "$file_num" -gt $nlines -o "$file_num" -lt 0 ]
            then
                fmt_mesg "'$file_num' is out of range.
                    Please input a number from 0 to $nlines."
                continue
            elif [ "$file_num" -eq 0 ]
            then
                get_lic_file_name
                if [ -n "$filename" ]
                then
                    break
                else
                    continue
                fi
            else
                filename=`awk "{ if ( NR == $file_num ) print }" \
                    < /tmp/lic_files.$$`
                if verify_lic_file_name
                then
                    break
                else
                    continue
                fi
            fi
        done

        SV_LIC_FILE_NAME=$filename
        save_vars
    fi

    fmt_mesg "Will use $SV_LIC_FILE_NAME as the license file."
    separator
}

#------------------------------------------------------------------------
delete_server() {
#------------------------------------------------------------------------
#
# Remove server from list of servers.
#

    mv $SV_LIC_FILE_NAME $SV_LIC_FILE_NAME.bak
    awk "/^SERVER / { count++; if (count != $1) { print; } next; } { print; }"\
        < $SV_LIC_FILE_NAME.bak > $SV_LIC_FILE_NAME
    SERVER_COUNT=`expr $SERVER_COUNT - 1`
    /bin/rm -f $SV_LIC_FILE_NAME.bak
}

#------------------------------------------------------------------------
replace_server() {
#------------------------------------------------------------------------
#
# Restore previous server list.
#
# Input: server_num
#
    get_server $server_num  # Set def_server based on server_num
    sed  -e "s?^SERVER $def_server .*?SERVER $SERVER $HOSTID $PORT?" \
        $SV_LIC_FILE_NAME > $SV_LIC_FILE_NAME.new
    cp $SV_LIC_FILE_NAME.new $SV_LIC_FILE_NAME
    /bin/rm -f $SV_LIC_FILE_NAME.new
}

#------------------------------------------------------------------------
get_max_servers() {
#------------------------------------------------------------------------
#
# Determine the number of servers.  If less are selected than in
# the license file, then ask user to delete.  Set max_servers.
#

    verbose "The license manager software used by $product_name allows you
        to have multiple license server hosts configured for redundancy
        against server crashes.  Most configurations will only need one
        server, usually the NFS server that your users' workstations
        use to get access to the $product_name."

    verbose "You may choose 1, 3, or 5 license server hosts.  In a
        multi-host configuration,  a majority of the hosts must
        answer a license query for before the token will be granted."

    if [ $feature = rose ]
    then
        verbose "If you have purchased a node-locked license for
            $product_name, then it must serve as the only license server.
            Node-locking binds the product to a single machine.  Otherwise,
            a floating license mechanism is used."
    fi

    case $SERVER_COUNT in
        1)
            max_servers=1
            get_yn "Is this going to be a node-locked license?" $SV_NODE_LOCKED
            SV_NODE_LOCKED=$result
            save_vars
            ;;
        3|5)
            max_servers=$SERVER_COUNT
            ;;
        0|"" )
            SERVER_COUNT=0
            max_servers=1
            get_yn "Is this going to be a node-locked license?" $SV_NODE_LOCKED
            SV_NODE_LOCKED=$result
            save_vars
            ;;
        2 )
            fmt_mesg "You have 2 servers defined in your license file.
                Since you can only have 1, 3 or 5, you must either
                delete or add some."
            max_servers=1
            ;;
        4 )
            fmt_mesg "You have 4 servers defined in your license file.
                Since you can only have 1, 3 or 5, you must either
                delete or add some."
            max_servers=3
            ;;
        * )
            fmt_mesg "You have 6 or more servers defined in your license file.
                Since you can have no more than 5 you must delete the
                excess."
            max_servers=5
            ;;
    esac

    if [ "$SV_NODE_LOCKED" = yes ]
    then
        verbose "The node-locking mechanism locks $product_name to both
            a host and a display.  The display name needs to be entered
            in the form 'xyz:0.0' for your license to work."

        get_input "Enter the display you are locking $product to:" $DISPLAY
        SV_DISPLAY=$result
        save_vars
    else
        while true
        do
            get_input "Enter number of license servers (1,3,5):" $max_servers
            case $result in
                1|3|5)
                       max_servers=$result
                       break
                       ;;
                    *)
                       echo "You must enter either a 1, 3, or 5."
                       ;;
            esac
        done
    fi

    edit_servers
}



#------------------------------------------------------------------------
set_license_arch() {
#------------------------------------------------------------------------
#
# Set the license_arch from remote license server.
#
# arg1: remote license server -- if not set use the first SERVER
#       in the license file.
#

    if [ -n "$1" ]
    then
        remote_server=$1
    else
        set -- `grep "^SERVER" $SV_LIC_FILE_NAME | head -1`
        remote_server=$2
    fi

    remote_uname=`rsh $remote_server uname -s`
    case $remote_uname in
          AIX ) license_arch=rs6k ;;
        SunOS ) license_arch=sun4 ;;
            * ) license_arch=unknown ;;
    esac
}


#------------------------------------------------------------------------
check_hw_arch() {
#------------------------------------------------------------------------
#
# Verify hardware architecture of SERVER.  Set license_arch.
#
# input: server_num
#

    # Set license_arch on first SERVER.
    if [ $1 -eq 1 ]
    then
        if [ $HOSTNAME = $SERVER ]
        then
            license_arch=$ARCH
            return $TRUE
        elif [ $SV_VERIFY_WITH_RSH = yes ]
        then
            remote_uname=`rsh $SERVER uname -s`
            case $remote_uname in
                  AIX ) license_arch=rs6k; return $TRUE ;;
                SunOS ) license_arch=sun4; return $TRUE ;;
                    * ) license_arch=unknown; return $FALSE ;;
            esac
        else
            # Can't check
            return $TRUE
        fi
    fi

    # On subsequent servers, check license_arch matches SERVER.
    if [ $HOSTNAME = $SERVER ]
    then
        if [ "$license_arch" = $ARCH ]
        then
            return $TRUE
        elif [ $SV_VERIFY_WITH_RSH = no ]
        then
            # Can't check
            return $TRUE
        else
            warning "$SERVER architecture ($ARCH) does not match first server
                architecture ($license_arch)."
            fmt_mesg "Remember, all license servers must be of the same
                hardware architecture type."
            return $FALSE
        fi
    fi

    if [ $SV_VERIFY_WITH_RSH = no ]
    then
        # Can't check
        return $TRUE
    fi

    remote_uname=`rsh $SERVER uname -s`
    case $remote_uname in
          AIX ) rem_arch=rs6k ;;
        SunOS ) rem_arch=sun4 ;;
            * ) rem_arch=unknown ;;
    esac

    if [ -z "$license_arch" ]
    then
        set_license_arch
    fi

    if [ "$rem_arch" = "$license_arch" ]
    then
        return $TRUE
    else
        warning "$SERVER architecture ($rem_arch) does not match first
            server architecture ($license_arch)."
        fmt_mesg "Remember, all license servers must be of the same hardware
            architecture type."
        return $FALSE
    fi

}


#------------------------------------------------------------------------
get_servername() {
#------------------------------------------------------------------------
#
# Get server name from user.  Set SERVER.
#
# input: server_num
#

    server_num=$1

    echo
    echo "All license servers must be of the same hardware architecture type."
    while true
    do
        if [ $max_servers -gt 1 ]
        then
            nth=${server_num}`set_ord $server_num` # 1st, 2nd, 3rd, 4th,...nth
            get_input "Input the $nth hostname to use as a license server:"\
                $def_server
        else
            get_input "Input the hostname to use as a license server:"\
                $def_server
        fi
        SERVER=$result

        if [ -z "$SERVER" ]
        then
            fmt_mesg "There is no default $nth server host.
                Please enter a hostname."
            continue
        fi

        # Check for duplicate
        if check_hw_arch $server_num
        then
            :
        else
            continue
        fi

        if [ $server_num -ne 0  -a  -f $SV_LIC_FILE_NAME ]
        then
            if grep "^SERVER $SERVER" $SV_LIC_FILE_NAME >/dev/null
            then
                fmt_mesg "$SERVER is already mentioned as a server host in
                    $SV_LIC_FILE_NAME.  Choose another host."
                continue
            fi
        fi


        # Check hostname (sets HOSTID and PORT) 
        verify_server
        if [ $? -eq $FALSE ]
        then
            echo "$SERVER is an invalid hostname.  Try again."
            continue
        fi

        get_yn "$SERVER seems to be a valid host.  Use it for a license server?" yes
        if [ $result = yes ]
        then
            break
        fi
    done
}

#------------------------------------------------------------------------
edit_servers() {
#------------------------------------------------------------------------
#
# Present a list of servers to user.  Allow them to add/delete/edit servers.
#

    separator

    if [ $USE_LIC_FILE = yes ]
    then
        if [ $SERVER_COUNT -gt $max_servers ]
        then
            del=`expr $SERVER_COUNT - $max_servers`
            s=`set_s $del`
            fmt_mesg "You have selected a number of license servers that is less
                than the number currently defined in your license file.
                You will need to select $del server$s to delete."
        elif [ $SERVER_COUNT -lt $max_servers ]
        then
            add=`expr $max_servers - $SERVER_COUNT`
            s=`set_s $add`
            fmt_mesg "You have selected a number of license servers that is
                greater than the number currently defined in your license
                file.  You will need to select $add server$s to add."
        fi
    fi

    verbose "This script has the capability of using the remote shell
        protocol to get required information from a host that you
        wish to use as a license server."

    verbose "In order to use this functionality, the rsh command must
        be able to get to the host$s that you wish to use for your
        license server$s."

    verbose "If local site security restrictions prevent the rsh program
        from functioning properly, and the license server you wish
        to add is not the host that this script is running on, you
        will have to get the information asked for manually.  See
        the installation documentation for directions on how to
        obtain the required information."

    get_yn "Should this script use rsh to access remote license server hosts?"\
        $SV_VERIFY_WITH_RSH
    SV_VERIFY_WITH_RSH=$result
    save_vars


    #
    # Delete SERVERs
    #
    a=a
    while [ $SERVER_COUNT -gt $max_servers ]
    do
        echo
        echo "Pick $a server to delete:"
        dump_servers

        get_input "Which server to delete? (1 to $SERVER_COUNT):" $SERVER_COUNT
        server_num=$result
        if [ $server_num -lt 1 -o $server_num -gt $SERVER_COUNT ]
        then
            echo "You must input a number between 1 and $SERVER_COUNT."
            continue
        fi

        delete_server $server_num
        del=`expr $del - 1`
        a=another
    done

    #
    # Add SERVERs
    #
    while [ $SERVER_COUNT -lt $max_servers ]
    do
        if [ $SERVER_COUNT -eq 0 ]
        then
            def_server=$HOSTNAME
        elif [ $SERVER_COUNT -gt 0 ]
        then
            echo
            echo "Server(s):"
            dump_servers
            def_server=
        fi

        SERVER_COUNT=`expr $SERVER_COUNT + 1`
        get_servername $SERVER_COUNT
        echo "SERVER $SERVER $HOSTID $PORT" >> $SV_LIC_FILE_NAME
    done


    #
    # Edit hosts
    #
    s=`set_s $SERVER_COUNT`

    while true
    do
        if [ "$SERVER_COUNT" = 1 ]
        then
            fmt_mesg "Now you have an opportunity to edit the license
                server$s defined in your license file.
                The following hosts are defined as license servers:"
        else
            fmt_mesg "Now you have an opportunity to edit the license
                server$s defined in your license file.
                The following hosts are defined as license servers:"
        fi
        dump_servers

        get_input "Enter the number of the server you wish to change, 0=continue:" 0
        server_num=$result

        if [ "$server_num" -gt $SERVER_COUNT -o "$server_num" -lt 0 ]
        then
            echo "You must enter a number from 1 to $SERVER_COUNT, or 0 to continue."
            continue
        fi

        if [ $server_num -eq 0 ]
        then
            break
        fi

        get_servername $server_num

        replace_server
    done
}


#-----------------------------------------------------------------
output_data() {
#-----------------------------------------------------------------
# Display licensing information

    ul="_______________________"
    s=`set_s $SERVER_COUNT`
    separator

    echo "Licensing information for:"
    echo
    echo "    Product: $product_name"
    echo "    Licensing Version: $license_version"
    echo "    $vendor Technical Support:"
    cat support.phone
    echo
    echo "$SERVER_COUNT license server host$s:"

    dump_servers

    if [ "$SV_NODE_LOCKED" = yes ]
    then
        echo
        echo "    Node-locked display: $SV_DISPLAY"
    fi

    fmt_mesg "Daemon Directory Path: $DAEMON_PATH"

    fmt_mesg "Other information that you will need:"
    echo
    echo "    Number of Licenses?  $ul"
    echo
    echo "    Expiration Date?     $ul"

    fmt_mesg "After calling $vendor technical support,
        you will be given a FEATURE line that looks something like this:"

    echo
    echo "    FEATURE $license_feature rational $license_version 01-jan-94 10 CF004576227FABD45816 \"$SV_DISPLAY\" $SV_NL_HOSTID"

    fmt_mesg "The expiration date, number of licenses and the license key
        may be different.  Make sure you are still in the 'install' directory.
        You will need to do the following before running
        $product_name:"

    fmt_mesg "1) Run the command add_license_info to either add or change the
        license file $SV_LIC_FILE_NAME:"
    echo
    echo "    % ./add_license_info"

    fmt_mesg "2) As root, run the command start_lm to add the lmgrd daemon
        invocation to $init_file.  You will be asked if you want to
        start the license daemon.  You will need to do this before
        you run the post_install.  If the license daemon is already
        running, you can use start_lm to tell the daemon to reread its
        license.dat file."
    echo
    echo "    % su               # become root"
    echo "    root> ./start_lm   # Start or re-start the license daemon"
    echo "    ..."
    echo "    root> exit"
    echo "    %"

    fmt_mesg "The start_lm script will append the file $INVOCATION to
        $init_file if it determines that the lmgrd daemon is not listed
        in the file already.  It will verify if the license server
        daemon is running"

    fmt_mesg "3) Run the post_install script:"
    echo
    echo "    % ./post_install"

    fmt_mesg "The above licensing information has been saved in the file
        '$license_info'."
}

#========================================================================
# MAIN
#========================================================================

#-----------------------------------------------------------------
# Make sure that APEX_HOME or ROSE is setup.
#-----------------------------------------------------------------
case $feature in
    apex )
        BASE_VAR=APEX_HOME
        if [ -n "$APEX_HOME" ]
        then
            phys_cur_home=`cpath $APEX_HOME`
            if [ "$def_home" != "$phys_cur_home" ]
            then
                echo
                echo "APEX_HOME ($APEX_HOME)"
                echo "is not the same as the parent of the install directory"
                echo "($def_home)"
                echo "APEX_HOME will be set to $def_home."
                get_yn "Do you want to continue?" yes
                if [ "$result" = no ]
                then
                    exit 1
                fi
                APEX_HOME=$def_home
            fi
        else
            APEX_HOME=$def_home
        fi

        PROD_HOME=$APEX_HOME
        LICENSE_SUN4=$APEX_HOME/sun4/cots/license
        LICENSE_RS6K=$APEX_HOME/rs6k/cots/license
        LICENSE_DIR=$APEX_HOME/$ARCH/cots/license
        export APEX_HOME
        ;;

    rose )
        BASE_VAR="ROSE home"
        if [ -z "$ROSE" ]
        then
            ROSE=`get_var INST_HOMEDIR`
        fi

        if [ -z "$ROSE" ]
        then
            fatal "ROSE must be defined.  Have you run 'install' yet?"
        fi

        if [ ! -d "$ROSE" ]
        then
            fatal "$ROSE not found"
        fi

        PROD_HOME=$ROSE
        LICENSE_SUN4=$ROSE/license/sun4
        LICENSE_RS6K=$ROSE/license/rs6k
        LICENSE_DIR=$ROSE/license/$ARCH
        export ROSE
        ;;

    * )
        BASE_VAR=APEX_HOME
        if [ -z "$APEX_HOME" ]
        then
            echo APEX_HOME must be defined
            exit 1
        fi

        PROD_HOME=$APEX_HOME
        LICENSE_SUN4=$APEX_HOME/sun4/cots/license
        LICENSE_RS6K=$APEX_HOME/rs6k/cots/license
        LICENSE_DIR=$APEX_HOME/$ARCH/cots/license
        export APEX_HOME
        ;;
esac


#-----------------------------------------------------------------
# Banner
#-----------------------------------------------------------------
separator
fmt_mesg "$product_name home directory: $PROD_HOME"
echo "Setting up license for version: $product_version"
echo "System architecture: $ARCH"

#-----------------------------------------------------------------
# Make sure that we have PATHs to where we need to run things from
# and that the appropriate architecture is set.
#-----------------------------------------------------------------
if [ -d $PROD_HOME/share/bin ]
then
    PATH=$PROD_HOME/share/bin:$PATH
fi

if [ -d $PROD_HOME/$ARCH/bin ]
then
    PATH=$PROD_HOME/$ARCH/bin:$PATH
fi

#-----------------------------------------------------------------
# Check system requirements
#-----------------------------------------------------------------
if [ -x ./check_reqs ]
then
    ./check_reqs -install
    if [ $? -gt 1 ]
    then
        # Abort this script
        fmt_mesg "Cannot continue until required system parameters
            have been satisfied."
        exit 1
    fi
fi

#-----------------------------------------------------------------
# Restore parameters from previous run.
# Save variables upon interrupt or exit.
#-----------------------------------------------------------------
load_vars

#-----------------------------------------------------------------
# Query user for options.
#-----------------------------------------------------------------
separator
fmt_mesg "This script will assist you in gathering the information that
    $vendor technical support will need to give you your license
    key for the $product_name."

fmt_mesg "As some of the questions can be a little complex, you have the option
    of more detailed explanations before each question."

get_yn "Do you wish the extended descriptions of questions? " $SV_VERBOSE_MODE
SV_VERBOSE_MODE=$result
save_vars
if [ $SV_VERBOSE_MODE = yes ]
then
    echo
    echo "Okay, this script will run in VERBOSE mode."
    press_cr
fi

#-----------------------------------------------------------------
# Look for a license file ...
#-----------------------------------------------------------------
separator
case $ARCH in
    rs6k )
           init_file=/etc/inittab
           ;;
    sun4 )
           init_file=/etc/rc.local
           ;;
       * )
           init_file=/etc/inittab
           ;;
esac

# DEF_LIC_FILE_NAME is what was found in system init file or
# the rational config directory license.dat file.
APEX_LIC_FILE_NAME=$rational_dir/config/license.dat
if [ -r "$init_file" ]
then
    sed -e 's/ /\
/g' $init_file | grep 'license\.dat' > /tmp/def_lic.$$
    DEF_LIC_FILE_NAME=`head -1 /tmp/def_lic.$$`
    /bin/rm -f /tmp/def_lic.$$
fi

if [ -z "$DEF_LIC_FILE_NAME" ]
then
    DEF_LIC_FILE_NAME=$APEX_LIC_FILE_NAME
else
    if [ "$DEF_LIC_FILE_NAME" != "$APEX_LIC_FILE_NAME" ]
    then
        fmt_mesg "The default license.dat file is not in the common
           <rational_dir>/config directory.
           You can take this opportunity to move it there. It is recommended
           that you move $DEF_LIC_FILE_NAME to $APEX_LIC_FILE_NAME."
    
        get_yn "Is it okay to do this now?" yes
        if [ "$result" = yes ]
        then
            if mv $DEF_LIC_FILE_NAME $APEX_LIC_FILE_NAME
            then
                DEF_LIC_FILE_NAME=$APEX_LIC_FILE_NAME
            else
                fmt_mesg "You do not have permissions to move it.  The file will
                    be left in `basename $DEF_LIC_FILE_NAME`"
            fi
        fi
    fi
fi


# SV_LIC_FILE_NAME is the previous license.dat file selected or
# the default as determined above.
SV_LIC_FILE_NAME=${SV_LIC_FILE_NAME:-$DEF_LIC_FILE_NAME}
save_vars

if is_lic_file "$DEF_LIC_FILE_NAME" >/dev/null
then
    USE_LIC_FILE=yes
    fmt_mesg "License file found: $DEF_LIC_FILE_NAME"
elif is_lic_file "$SV_LIC_FILE_NAME" >/dev/null
then
    DEF_LIC_FILE_NAME=$SV_LIC_FILE_NAME
    USE_LIC_FILE=yes
    fmt_mesg "License file found: $SV_LIC_FILE_NAME"
else
    USE_LIC_FILE=no
fi

verbose "You have the option of using an existing license file for the
    SERVER and DAEMON lines used to generate the license key."

get_yn "Do you wish to use an existing file for SERVER and DAEMON lines?" \
       $USE_LIC_FILE
USE_LIC_FILE=$result

find_license_files
select_license_file

if [ $USE_LIC_FILE = yes ]
then
    SERVER_COUNT=`grep -c '^SERVER ' $SV_LIC_FILE_NAME`
    s=`set_s $SERVER_COUNT`
    echo "License file configured for $SERVER_COUNT server$s"
else
    SERVER_COUNT=0
fi


if [ -f $SV_LIC_FILE_NAME ]
then
    if grep '^FEATURE' $SV_LIC_FILE_NAME >/dev/null
    then
        max_servers=$SERVER_COUNT
        s=`set_s $SERVER_COUNT`
        verbose "Since the license file you have chosen to use currently has
            FEATURE lines in it, the $SERVER_COUNT server$s and their
            names cannot be changed as this would cause the invalidation
            of the feature lines in the file."

        if [ $SV_VERBOSE_MODE = no ]
        then
            fmt_mesg "Warning - License file has features defined: \
                can't change SERVER lines."
        fi
    else
        verbose "NOTE: The license file you have chosen does not have any
            FEATURE lines defined in it, yet.  You may, if you wish,
            change the number of license servers defined by the file
            (currently $SERVER_COUNT).  If you wish to keep the default,
            simply press Return at the following prompt."
        get_max_servers
    fi
else
    get_max_servers
fi


#-----------------------------------------------------------------
# Get the daemon information.  We need to verify the pathname to
# the 'rational' license daemon.
#-----------------------------------------------------------------
separator

verbose "The DAEMON line in a license file tells the license manager where
    it can find the specific vendor daemon for a given product.
    The vendor daemon for the $product_name is called 'rational',
    and by default is installed as:"
verbose -i "$LICENSE_DIR"

verbose "This path is used by lmgrd when it is started to locate the
    'rational' daemon."


if grep '^DAEMON rational ' $SV_LIC_FILE_NAME >/dev/null 2>&1
then
    # Get path from file.
    verbose "You already have a DAEMON line in your license server file.
        This script will extract that path, and allow you to change
        it, if you wish."
    DAEMON_PATH=`grep '^DAEMON rational ' $SV_LIC_FILE_NAME | awk '{ print $3}'`
    NEED_DAEMON=no
else
    # Daemon line not found.  Use default path.
    verbose    "A DAEMON line was not found in the license file:"
    verbose -i "$SV_LIC_FILE_NAME."
    verbose    "You will need to enter the pathname to the $vendor daemon."
    DAEMON_PATH=$LICENSE_DIR
    NEED_DAEMON=yes
fi

while true
do
    echo "Enter the directory name containing vendor license daemon"
    get_input "dir:" $DAEMON_PATH
    daemon_path=$result
    if [ -d "$daemon_path" ]
    then
        if [ -x $daemon_path/rational ]
        then
            break
        else
            fmt_mesg "$daemon_path/rational not found. You must enter a
                directory name containing the 'rational' license daemon."
        fi
    else
        fmt_mesg "$daemon_path does not exist or is not a directory.
            You must enter a valid directory name."
    fi
done
DAEMON_PATH=$daemon_path

# Determine the architecture of the license server executables.

if [ -z "$license_arch" ]
then
    verbose "The machine architecture of the license server executables
        needs to be determined. This information will be used to determine
        which invocation entry to create for the system process
        initialization file.  This invocation entry will be needed for the
        next step in the licensing of $product_name."

    if echo $DAEMON_PATH | grep '/sun4' >/dev/null
    then
        def_license_arch=sun4
    elif echo $DAEMON_PATH | grep '/rs6k' >/dev/null
    then
        def_license_arch=rs6k
    fi
    get_input "Enter the machine architecture for this directory (sun4|rs6k):" \
        $def_license_arch
    license_arch=$result
fi

if [ $NEED_DAEMON = no ]
then
    # Replace current daemon path..
    sed -e "s?^DAEMON rational .*?DAEMON rational $DAEMON_PATH?g" \
        $SV_LIC_FILE_NAME > $SV_LIC_FILE_NAME.new
    cp $SV_LIC_FILE_NAME.new $SV_LIC_FILE_NAME
    /bin/rm -f $SV_LIC_FILE_NAME.new
else
    echo "DAEMON rational $DAEMON_PATH" >> $SV_LIC_FILE_NAME
fi


#-----------------------------------------------------------------
# Now we should have all the information that we need to pass back
# to Rational.  Output it in a nice form.
#-----------------------------------------------------------------
separator

fmt_mesg "That concludes all of the questions that are required to
    obtain your license key.  A partial license file is built
    in $SV_LIC_FILE_NAME.  The next screen of output, as well
    as the installation documentation, will explain in more
    detail the remaining steps to get you up and running with
    $product_name."

# Create the license manager invocation entries for Sparc or RS/6000s
LMGRD=$DAEMON_PATH/lmgrd
LOG=$DAEMON_PATH/license.log

touch $LOG 2>/dev/null
chmod 666 $LOG 2>/dev/null

if [ $license_arch = rs6k ]
then
    INVOCATION=lmgrd.rs6k
    echo "lmgrd:2:respawn:$LMGRD -c $SV_LIC_FILE_NAME >> $LOG 2>&1"\
        > $INVOCATION
elif [ $license_arch = sun4 ]
then
    INVOCATION=lmgrd.sun4
    cat <<EOF > $INVOCATION
# Run the license manager for $vendor
# (for entry in $init_file) 
#
if [ -f $LMGRD ]
then
	echo "Starting $vendor license manager daemon"
	$LMGRD \\
	-c $SV_LIC_FILE_NAME \\
	>> $LOG 2>&1 &
fi  # End of $vendor license manager invocation.
EOF
else
    warning "Unknown license server architecture--cannot create invocation
        entry for the system initialization file."
fi

license_info=license_information
output_data > $license_info

press_cr

put_var GET_LICENSE_INFO COMPLETED