From 408b16c5a50ffb35ee13c268d1a3fc85e5c690f1 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Fri, 4 Jul 2025 13:01:32 +0200 Subject: [PATCH] testing --- misc/core.func | 28 +++++++++++++++++++++------- misc/create_lxc.sh | 6 +++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/misc/core.func b/misc/core.func index b1dda6d3..2b7780e6 100644 --- a/misc/core.func +++ b/misc/core.func @@ -250,6 +250,17 @@ header_info() { fi } +ensure_tput() { + if ! command -v tput >/dev/null 2>&1; then + if grep -qi 'alpine' /etc/os-release; then + apk add --no-cache ncurses >/dev/null 2>&1 + elif command -v apt-get >/dev/null 2>&1; then + apt-get update -qq >/dev/null + apt-get install -y -qq ncurses-bin >/dev/null 2>&1 + fi + fi +} + # ------------------------------------------------------------------------------ # Handles specific curl error codes and displays descriptive messages. # ------------------------------------------------------------------------------ @@ -302,6 +313,11 @@ spinner() { done } +clear_line() { + tput cr 2>/dev/null || echo -en "\r" + tput el 2>/dev/null || echo -en "\033[K" +} + stop_spinner() { local pid="${SPINNER_PID:-}" [[ -z "$pid" && -f /tmp/.spinner.pid ]] && pid=$(&2 - else - echo -e "${BFR:-} ${CM:-✔️} ${GN}${msg}${CL}" - fi + [[ -z "$msg" ]] && return + stop_spinner + clear_line + printf "%s %b\n" "$CM" "${GN}${msg}${CL}" >&2 + unset MSG_INFO_SHOWN["$msg"] } msg_error() { diff --git a/misc/create_lxc.sh b/misc/create_lxc.sh index 98b4d68e..85d49e4a 100644 --- a/misc/create_lxc.sh +++ b/misc/create_lxc.sh @@ -73,7 +73,7 @@ if ! check_storage_support "vztmpl"; then msg_error "No valid storage found for 'vztmpl' (Template)." exit 1 fi -msg_ok "Storage types rootdir and vztmpl are supported." +msg_ok "Validated Storage (rootdir / vztmpl)." # This function is used to select the storage class and determine the corresponding storage content type and label. function select_storage() { @@ -153,7 +153,6 @@ function select_storage() { exit 202 } - # Validierung gegen STORAGE_MAP if [[ -z "$DISPLAY_SELECTED" || -z "${STORAGE_MAP[$DISPLAY_SELECTED]+_}" ]]; then whiptail --backtitle "Proxmox VE Helper Scripts" --title "Invalid Selection" \ --msgbox "No valid storage selected. Please choose a storage pool to continue." 9 60 @@ -298,6 +297,8 @@ if ! pveam list "$TEMPLATE_STORAGE" | grep -q "$TEMPLATE" || ! zstdcat "$TEMPLAT fi msg_ok "LXC Template '$TEMPLATE' is ready to use." + +msg_info "Creating LXC Container" # Check and fix subuid/subgid grep -q "root:100000:65536" /etc/subuid || echo "root:100000:65536" >>/etc/subuid grep -q "root:100000:65536" /etc/subgid || echo "root:100000:65536" >>/etc/subgid @@ -317,7 +318,6 @@ flock -w 60 9 || { exit 211 } -msg_info "Creating LXC Container" if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" &>/dev/null; then msg_error "Container creation failed. Checking if template is corrupted or incomplete."