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

guard_sourcing

#######################################
# Creates the DIRs, prepares the files and mounting paths for installation.
# Globals:
#   DIR_LOG
#   LOG_ERR
#   LOG_INS
#   LOG_NIC
#   VAR_PRESEED
# Arguments:
#  None
#######################################
gen_dir_files() {
  ### MAKE DIRS
  mkdir -p /tmp/.ciss/{backup,log,tmp} && chmod -R 0700 /tmp/.ciss
  mkdir -p "${TARGET}"
  mkdir -p "${RECOVERY}"
  mkdir -p "${VAR_SAFE_MNT_BASE}"

  ### TOUCH FILES
  touch "${LOG_ERR}" && chmod 0600 "${LOG_ERR}"
  touch "${LOG_INS}" && chmod 0600 "${LOG_INS}"
  touch "${LOG_NIC}" && chmod 0600 "${LOG_NIC}"
  touch "${LOG_UID}" && chmod 0600 "${LOG_UID}"
  touch "${LOG_DBS}" && chmod 0600 "${LOG_DBS}"
  touch "${VAR_PRESEED}" && chmod 0600 "${VAR_PRESEED}"
  touch "${DIR_LOG}/btrfs.log" && chmod 0600 "${DIR_LOG}/btrfs.log"
  touch "${DIR_LOG}/cpu.log" && chmod 0600 "${DIR_LOG}/cpu.log"
  touch "${DIR_LOG}/ext4.log" && chmod 0600 "${DIR_LOG}/ext4.log"
  touch "${DIR_LOG}/sshd_config.log" && chmod 0600 "${DIR_LOG}/sshd_config.log"
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
