PROCEDURE (hidden) rap$get_system_initiation_opt (
  installation_parameters, ip: (VAR) ..
*copy rat$installation_parameters
                                  = $required
  )

*IF $variable(rav$proc_doc,declared)<>'UNKNOWN'

" PURPOSE:
"   This procedure returns the system initiation control option values in
"   the installation_parameters record.
" METHOD:
"   Which menus/prompts are displayed to the user, and therefore which
"   control values are returned is based upon variables set at system core
"   command entry.
"
"   Input variables and their source:
"     RAV$SYSTEM_ACTIVATION - boolean set via system attribute SYSTEM_ACTIVATION.
"     OSV$DEADSTART_PHASE - INITIAL/NORMAL set via use (or not) of INITIALIZE_DEADSTART_DEVICE command.
"     OSV$OPERATOR_INTERVENTION - true if system core command entry terminated with GO instead of AUTO.
"     RAV$JOBS_RECOVERED - TRUE if there are executing jobs to recover.
"     The presence of deferred files for installation also influences the users choices.
"
"   Factors for determining if user is prompted:
"     If OSV$OPERATOR_INTERVENTION is TRUE (operator terminated system core with GO),
"       the RAV$SYSTEM_ACTIVATION value is ignored and ACTIVATION_OPTION is set to MANUAL.
"     If OSV$OPERATOR_INTERVENTION is FALSE (operator terminated system core with AUTO),
"       ACTIVATION_OPTION is set to MANUAL if RAV$SYSTEM_ACTIVATION is false or to
"       AUTOMATIC if RAV$SYSTEM_ACTIVATION is true.
"     The user will be prompted if ACTIVATION_OPTION is MANUAL.
"
"   Processing possibilities:
"     -------------- Inputs -------------      Result
"      DST_PH  ACT_OPT    JOB_REC  DEF_FIL
"     initial  production   n/a      n/a       Automatically install the Installation Tape without prompting.
"                                              Activate production.
"     initial    manual     n/a      n/a       IO, AO set based upon get_initial_option prompt.
"     normal   production   n/a      n/a       Activate the system for production without prompting.
"     normal     manual    false    false      IO, AO set based upon get_normal_option prompt.
"     normal     manual    false    true       IO, AO set based upon get_normal_deferred_option prompt.
"     normal     manual    true      n/a       IO=NONE, activation determined by get_activation_option prompt.
"
"     n/a means value of this variable or condition is not a consideration
"
*IFEND


  WHEN any_fault DO

    installation_parameters.installation_option = 'NONE'
    installation_parameters.activation_option = 'CONSOLE'

    $system.put_line ' '//$strrep($status(false, 'RA', rae$establishing_error, 'system initiation option')) o=$response
    $system.put_line ' '//$strrep(osv$status) o=$response

    IF $variable(rav$errors_occurred, nonlocal) THEN
      "$FORMAT=OFF
      VAR
        rav$errors_occurred: (XREF) boolean
      VAREND
      "$FORMAT=ON"
      rav$errors_occurred = true
    IFEND

    rap$display_message mm=initiation_messages mn=continuing_without_action t=$output status=ignore_status

    rap$log_system_initiation_opt ip=installation_parameters

    EXIT procedure
  WHENEND


  "$FORMAT=OFF
  VAR
    deferred_products: boolean
    ignore_status: status
    menu_selection: string 0 .. $max_name
    osv$deadstart_phase: (XREF) string 0 .. $max_name
    osv$operator_intervention: (XREF) boolean
    packing_list_name_valid: boolean
    rav$jobs_recovered: (XREF) boolean
    rav$system_activation: (XREF) boolean
  VAREND
  "$FORMAT=ON"


  IF osv$operator_intervention THEN
    installation_parameters.activation_option = 'MANUAL'
  ELSEIF rav$system_activation THEN
    installation_parameters.activation_option = 'PRODUCTION'
  ELSE
    installation_parameters.activation_option = 'MANUAL'
  IFEND

  installation_parameters.installation_option = 'NONE' "initialize field

  IF installation_parameters.activation_option = 'PRODUCTION' THEN
    IF osv$deadstart_phase = 'INSTALL' THEN
      packing_list_name_valid = false
      rap$validate_packing_list_name installation_parameters.packing_list require_user_acknowledgement=true ..
        plnv=packing_list_name_valid
      if packing_list_name_valid then
        installation_parameters.installation_option = 'INSTALLATION_TAPE'
      else
        rap$get_initial_option ip=installation_parameters first_menu=install_tape_menu
      ifend
    ELSE
      installation_parameters.installation_option = 'NONE'
    IFEND
  ELSE
    IF osv$deadstart_phase  = 'INSTALL' THEN
      rap$get_initial_option ip=installation_parameters first_menu=initiation_menu
    ELSEIF rav$jobs_recovered THEN
      installation_parameters.installation_option = 'NONE'
      rap$get_activation_option menu_module=jobs_rec_activation ao=installation_parameters.activation_option
    ELSE
      rap$check_for_deferred_products deferred_products
      IF deferred_products THEN
        rap$get_normal_deferred_option ip=installation_parameters
      ELSE
        rap$get_normal_option ip=installation_parameters
      IFEND
    IFEND
  IFEND

  rap$log_system_initiation_opt ip=installation_parameters

PROCEND rap$get_system_initiation_opt

