#!/bin/bash
# SPDX-Version: 3.0
# SPDX-CreationInfo: 2025-02-13; WEIDNER, Marc S.; <cendev@coresecret.eu>
# SPDX-ExternalRef: GIT https://cendev.eu/marc.weidner/CISS.2025.debian.installer.git
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <cendev@coresecret.eu>
# SPDX-FileType: SOURCE
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
# SPDX-LicenseComment: This file is part of the CISS.2025.hardened.installer framework.
# SPDX-PackageName: CISS.2025.hardened.installer
# SPDX-Security-Contact: security@coresecret.eu

###########################################################################################
# 3.8.9. Functions - installation - wrapper recovery                                      #
###########################################################################################

###########################################################################################
# Wrapper to check if recovery partition is selected and if so, proceed with setup of recovery OS.
# Globals:
#   MAP_MOUNTPATH_DEV
#   MODULE_ERR
#   MODULE_TXT
# Arguments:
#   None
###########################################################################################
3_8_9_functions_installation_wrapper_recovery() {
  declare -g -x MODULE_ERR="3_8_9_functions_installation_wrapper_recovery"
  declare -g -x MODULE_TXT="Wrapper recovery partition"
  do_show_header "${MODULE_TXT}"

  declare FOUND="false"
  declare MOUNT_PATH=""
  declare HASHMAP_VALUE=""

  for MOUNT_PATH in "${!MAP_MOUNTPATH_DEV[@]}"; do
    HASHMAP_VALUE="${MAP_MOUNTPATH_DEV[${MOUNT_PATH}]}"
    if [[ ${HASHMAP_VALUE} == "/dev/mapper/crypt_rescue" ]]; then
      FOUND="true"
      break
    fi
  done

  if [[ ${FOUND} == true ]]; then
    3_9_0_functions_installation_setup_recovery
    3_9_1_functions_installation_generate_files_recovery
  fi

  do_show_footer "${MODULE_TXT}"
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh:
