diff --git a/ciss_live_builder.sh b/ciss_live_builder.sh index 07d928f..a41655a 100644 --- a/ciss_live_builder.sh +++ b/ciss_live_builder.sh @@ -47,16 +47,57 @@ declare -gx VAR_VERSION="Master V8.03.768.2025.06.18" for arg in "$@"; do case "${arg,,}" in -c|--contact) . ./lib/lib_contact.sh; contact; exit 0;; esac; done for arg in "$@"; do case "${arg,,}" in -h|--help) . ./lib/lib_usage.sh; usage; exit 0;; esac; done for arg in "$@"; do case "${arg,,}" in -v|--version) printf "\e[95mCISS.debian.live.builder Version: %s\e[0m\n" "${VAR_VERSION}"; exit 0;; esac; done +declare -gx VAR_SETUP="true" + +### SOURCING VARIABLES +[[ "${VAR_SETUP}" == true ]] && { + . ./var/bash.var.sh + . ./var/color.var.sh + . ./var/global.var.sh +} + +### SOURCING LIBRARIES +[[ "${VAR_SETUP}" == true ]] && { + . ./lib/lib_arg_parser.sh + . ./lib/lib_arg_priority_check.sh + . ./lib/lib_boot_screen.sh + . ./lib/lib_cdi.sh + . ./lib/lib_change_splash.sh + . ./lib/lib_check_dhcp.sh + . ./lib/lib_check_hooks.sh + . ./lib/lib_check_kernel.sh + . ./lib/lib_check_pkgs.sh + . ./lib/lib_check_provider.sh + . ./lib/lib_check_stats.sh + . ./lib/lib_check_var.sh + . ./lib/lib_clean_screen.sh + . ./lib/lib_clean_up.sh + . ./lib/lib_copy_integrity.sh + . ./lib/lib_debug.sh + . ./lib/lib_debug_header.sh + . ./lib/lib_hardening_root_pw.sh + . ./lib/lib_hardening_ssh.sh + . ./lib/lib_hardening_ultra.sh + . ./lib/lib_helper_ip.sh + . ./lib/lib_lb_build_start.sh + . ./lib/lib_lb_config_start.sh + . ./lib/lib_lb_config_write.sh + . ./lib/lib_provider_netcup.sh + . ./lib/lib_run_analysis.sh + . ./lib/lib_sanitizer.sh + . ./lib/lib_trap_on_err.sh + . ./lib/lib_trap_on_exit.sh + . ./lib/lib_usage.sh +} ### VERY EARLY CHECK FOR XTRACE DEBUGGING if [[ $* == *" --debug "* ]]; then - . ./lib/lib_debug.sh debugger "${@}" else declare -gx VAR_EARLY_DEBUG=false fi -### Advisory Lock +### ADVISORY LOCK exec 127>/var/lock/ciss_live_builder.lock || { . ./var/global.var.sh printf "\e[91m❌ Cannot open lockfile for writing! Bye... \e[0m\n" >&2 @@ -75,30 +116,17 @@ for arg in "$@"; do case "${arg,,}" in -a=*|--autobuild=*) declare -gx VAR_HANDL unset arg for dir in /usr/local/sbin /usr/sbin; do case ":${PATH}:" in *":${dir}:"*) ;; *) PATH="${PATH}:${dir}" ;; esac; done; export PATH; unset dir -### Checking required packages -. ./lib/lib_check_pkgs.sh +### CHECKING REQUIRED PACKAGES check_pkgs -### Dialog Output for Initialization -if ! $VAR_HANDLER_AUTOBUILD; then . ./lib/lib_boot_screen.sh && boot_screen; fi +### DIALOG OUTPUT FOR INITIALIZATION +if ! $VAR_HANDLER_AUTOBUILD; then boot_screen; fi ### Updating Status of Dialog Gauge Bar -if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nUpdating variables ... \nXXX\n05\n" >&3; fi -. ./var/global.var.sh -. ./var/colors.var.sh +if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nInitialization done ... \nXXX\n15\n" >&3; fi ### Updating Status of Dialog Gauge Bar -if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nEnabling Bash Error Handling ... \nXXX\n15\n" >&3; fi -### For all options see https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin -set -o errexit # Exit script when a command exits with non-zero status, the same as "set -e". -set -o errtrace # Any traps on ERR are inherited in a subshell environment, the same as "set -E". -set -o functrace # Any traps on DEBUG and RETURN are inherited in a subshell environment, the same as "set -T". -set -o nounset # Exit script on use of an undefined variable, the same as "set -u". -set -o pipefail # Makes pipelines return the exit status of the last command in the pipe that failed. -set -o noclobber # Prevent overwriting, the same as "set -C". - -### Updating Status of Dialog Gauge Bar -if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nAdditional initialization ... \nXXX\n25\n" >&3; fi +if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nAdditional initialization ... \nXXX\n30\n" >&3; fi ### Initialization declare -gr ARGUMENTS_COUNT="$#" declare -gr ARG_STR_ORG_INPUT="$*" @@ -111,42 +139,13 @@ declare -grx SCRIPT_BASEPATH="$(dirname "${SCRIPT_FULLPATH}")" declare -grx VAR_WORKDIR="$(dirname "${SCRIPT_FULLPATH}")" ### Updating Status of Dialog Gauge Bar -if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nSourcing Libraries ... \nXXX\n50\n" >&3; fi -. ./lib/lib_arg_parser.sh -. ./lib/lib_arg_priority_check.sh -. ./lib/lib_cdi.sh -. ./lib/lib_change_splash.sh -. ./lib/lib_check_dhcp.sh -. ./lib/lib_check_hooks.sh -. ./lib/lib_check_kernel.sh -. ./lib/lib_check_provider.sh -. ./lib/lib_check_stats.sh -. ./lib/lib_check_var.sh -. ./lib/lib_clean_screen.sh -. ./lib/lib_clean_up.sh -. ./lib/lib_copy_integrity.sh -. ./lib/lib_hardening_root_pw.sh -. ./lib/lib_hardening_ssh.sh -. ./lib/lib_hardening_ultra.sh -. ./lib/lib_helper_ip.sh -. ./lib/lib_lb_build_start.sh -. ./lib/lib_lb_config_start.sh -. ./lib/lib_lb_config_write.sh -. ./lib/lib_provider_netcup.sh -. ./lib/lib_run_analysis.sh -. ./lib/lib_sanitizer.sh -. ./lib/lib_trap_on_err.sh -. ./lib/lib_trap_on_exit.sh -. ./lib/lib_usage.sh - -### Updating Status of Dialog Gauge Bar -if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nActivate traps ... \nXXX\n55\n" >&3; fi +if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nActivate traps ... \nXXX\n50\n" >&3; fi ### Following the CISS Bash naming and ordering scheme trap 'trap_on_exit "$?"' EXIT trap 'trap_on_err "$?" "${BASH_SOURCE[0]}" "${LINENO}" "${FUNCNAME[0]:-main}" "${BASH_COMMAND}"' ERR ### Updating Status of Dialog Gauge Bar -if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nSanitizing Arguments ... \nXXX\n70\n" >&3; fi +if ! $VAR_HANDLER_AUTOBUILD; then printf "XXX\nSanitizing Arguments ... \nXXX\n75\n" >&3; fi arg_check "$@" declare -ar ARY_ARG_SANITIZED=("$@") declare -gr VAR_ARG_SANITIZED="${ARY_ARG_SANITIZED[*]}" diff --git a/lib/lib_check_kernel.sh b/lib/lib_check_kernel.sh index 16fe973..eee8030 100644 --- a/lib/lib_check_kernel.sh +++ b/lib/lib_check_kernel.sh @@ -52,7 +52,7 @@ check_kernel() { done < "${VAR_KERNEL_SRT}" # shellcheck disable=SC2155 - if declare -g VAR_KERNEL=$(dialog \ + if declare -gx VAR_KERNEL=$(dialog \ --no-collapse \ --ascii-lines \ --clear \ @@ -63,9 +63,9 @@ check_kernel() { else clear if [[ "${VAR_ARCHITECTURE}" == "amd64" ]]; then - declare -gr VAR_KERNEL="amd64" + declare -gx VAR_KERNEL="amd64" elif [[ "${VAR_ARCHITECTURE}" == "arm64" ]]; then - declare -gr VAR_KERNEL="arm64" + declare -gx VAR_KERNEL="arm64" fi fi } diff --git a/var/bash.var.sh b/var/bash.var.sh new file mode 100644 index 0000000..3f99bb0 --- /dev/null +++ b/var/bash.var.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-Version: 3.0 +# SPDX-CreationInfo: 2025-05-05; WEIDNER, Marc S.; +# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.live.builder.git +# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency +# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; +# 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.live.builder +# SPDX-Security-Contact: security@coresecret.eu + +### For all options see https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin +set -o errexit # Exit script when a command exits with non-zero status, the same as "set -e". +set -o errtrace # Any traps on ERR are inherited in a subshell environment, the same as "set -E". +set -o functrace # Any traps on DEBUG and RETURN are inherited in a subshell environment, the same as "set -T". +set -o nounset # Exit script on use of an undefined variable, the same as "set -u". +set -o pipefail # Makes pipelines return the exit status of the last command in the pipe that failed. +set -o noclobber # Prevent overwriting, the same as "set -C". + +# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh diff --git a/var/colors.var.sh b/var/color.var.sh similarity index 95% rename from var/colors.var.sh rename to var/color.var.sh index 8214f99..4ee818f 100644 --- a/var/colors.var.sh +++ b/var/color.var.sh @@ -18,6 +18,6 @@ declare -grx C_BLU='\e[94m' # Organic blue. declare -grx C_MAG='\e[95m' # Super gay magenta. declare -grx C_CYA='\e[96m' # Lovely cyan. declare -grx C_WHI='\e[97m' # Fantastic color mix. -declare -grx C_RES='\e[0m' # Forget everything. +declare -grx C_RES='\e[0m' # Forget everything. # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh