From ad6e721898eae7b2959d4699e6558edf2d6d92a0984b1ca174863b9bd70e0700 Mon Sep 17 00:00:00 2001 From: "Marc S. Weidner" Date: Sat, 31 May 2025 08:57:19 +0200 Subject: [PATCH] V8.02.644.2025.05.31 Signed-off-by: Marc S. Weidner --- lib/lib_arg_parser.sh | 53 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/lib_arg_parser.sh b/lib/lib_arg_parser.sh index e504537..2e36311 100644 --- a/lib/lib_arg_parser.sh +++ b/lib/lib_arg_parser.sh @@ -101,7 +101,7 @@ arg_parser() { -c | --contact) if [[ -n "${2}" && "${2}" != -* ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --contact MUST NOT be followed by an argument.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -111,7 +111,7 @@ arg_parser() { -h | --help) if [[ -n "${2}" && "${2}" != -* ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --help MUST NOT be followed by an argument.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -121,7 +121,7 @@ arg_parser() { -v | --version) if [[ -n "${2}" && "${2}" != -* ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --version MUST NOT be followed by an argument.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -134,7 +134,7 @@ arg_parser() { declare -gx VAR_ARCHITECTURE="${2}" shift 2 else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --architecture MUST be 'amd64' or 'arm64'.\e[0m\n" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -150,7 +150,7 @@ arg_parser() { --cdi) if [[ -n "${2}" && "${2}" != -* ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --cdi MUST NOT be followed by an argument.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -164,7 +164,7 @@ arg_parser() { declare -g VAR_HANDLER_SPLASH="${2}" shift 2 else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --change-splash MUST be 'club' or 'hexagon'.\e[0m\n" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -173,11 +173,12 @@ arg_parser() { ;; --control) - if [[ -n "${2}" && "${2}" =~ ^-?[0-9]+$ && "${2}" -ge 1 && "${2}" -le 65536 ]]; then - declare -gi VAR_HANDLER_ISO_COUNTER="$2" + #if [[ -n "${2}" && "${2}" =~ ^-?[0-9]+$ && "${2}" -ge 1 && "${2}" -le 65536 ]]; then + if [[ -n "${2}" ]]; then + declare -gi VAR_HANDLER_ISO_COUNTER="${2}" shift 2 else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --control MUST be an integer between '1' and '65535'.\e[0m\n" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -187,7 +188,7 @@ arg_parser() { --debug) if [[ -n "${2}" && "${2}" != -* ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --debug MUST NOT be followed by an argument.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -197,7 +198,7 @@ arg_parser() { --dhcp-centurion) if [[ -n "${2}" && "${2}" != -* ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --dhcp-centurion MUST NOT be followed by an argument.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -219,7 +220,7 @@ arg_parser() { shift done else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --jump-host MUST contain one or up to ten IPs.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -228,7 +229,7 @@ arg_parser() { --log-statistics-only) if [[ -n "${2}" && "${2}" != -* ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --log-statistics-only MUST NOT be followed by an argument.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -252,7 +253,7 @@ arg_parser() { shift done else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --provider-netcup-ipv6 MUST provide one IPv6.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_ARG_MSMTCH}" @@ -264,7 +265,7 @@ arg_parser() { declare -gi VAR_HANDLER_PRIORITY="$2" shift 2 else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --renice-priority MUST an integer between '-19' and '19'.\e[0m\n" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -274,7 +275,7 @@ arg_parser() { --reionice-priority) if [[ -z "${2}" ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --reionice-priority no values provided.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_REIONICE_P}" @@ -287,14 +288,14 @@ arg_parser() { if [[ "${3}" =~ ^[0-7]$ ]]; then declare -gi VAR_REIONICE_PRIORITY="${3}" else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --reionice-priority PRIORITY MUST be an integer between '0' and '7'.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_REIO_P_VAL}" fi fi else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --reionice-priority CLASS MUST be an integer between '1' and '3'.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_REIO_C_VAL}" @@ -310,7 +311,7 @@ arg_parser() { --root-password-file) declare pw_file="${2}" if [[ -z "${pw_file}" ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --root-password-file missing password file path argument.\e[0m\n" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -318,7 +319,7 @@ arg_parser() { fi if [[ ! -f "${pw_file}" ]]; then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --root-password-file password file '%s' does not exist.\e[0m\n" "${pw_file}" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -329,7 +330,7 @@ arg_parser() { owner=$(stat -c '%U:%G' "${pw_file}") if [[ "${owner}" != "root:root" ]]; then chown root:root "${pw_file}" || { - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --root-password-file failed to set owner root:root on '%s'.\e[0m\n" "${pw_file}" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -341,7 +342,7 @@ arg_parser() { perms=$(stat -c '%a' "${pw_file}") if [[ "${perms}" -ne 400 ]]; then chmod 400 "${pw_file}" || { - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --root-password-file failed to set permissions 0400 on '%s'.\e[0m\n" "${pw_file}" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -359,7 +360,7 @@ arg_parser() { declare pw_length pw_length=${#plaintext_pw} if (( pw_length < 20 || pw_length > 64 )); then - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --root-password-file password MUST be between 20 and 64 characters (got %d).\e[0m\n" "${pw_length}" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -369,7 +370,7 @@ arg_parser() { [[ "${VAR_EARLY_DEBUG}" == "true" ]] && set +x # No tracing for security reasons if [[ "${plaintext_pw}" == *\"* ]]; then [[ "${VAR_EARLY_DEBUG}" == "true" ]] && set -x # Turn on tracing again - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --root-password-file password MUST NOT contain double quotes (\").\e[0m\n" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' @@ -409,7 +410,7 @@ arg_parser() { declare -gi VAR_SSHPORT="${2}" shift 2 else - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi printf "\e[91m❌ Error: --ssh-port MUST be an integer between '1' and '65535'.\e[0m\n" >&2 read -p -r $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR__SSH__PORT}" @@ -422,7 +423,7 @@ arg_parser() { ;; *) - boot_screen_cleaner + if ! $VAR_HANDLER_AUTOBUILD; then boot_screen_cleaner; fi usage ;; esac