From 569089cb73cd912e8e8d2a18ef15d118ab133ea9 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Fri, 4 Jul 2025 21:47:23 +0200 Subject: [PATCH] Update create_lxc.sh --- misc/create_lxc.sh | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/misc/create_lxc.sh b/misc/create_lxc.sh index 32f2207a0..1e18fc13f 100644 --- a/misc/create_lxc.sh +++ b/misc/create_lxc.sh @@ -113,7 +113,7 @@ function select_storage() { ;; esac - local -a MENU +local -a MENU local -A STORAGE_MAP local COL_WIDTH=0 @@ -181,13 +181,41 @@ if qm status "$CTID" &>/dev/null || pct status "$CTID" &>/dev/null; then exit 206 fi -# Get template storage -TEMPLATE_STORAGE=$(select_storage template) -msg_ok "Using ${BL}$TEMPLATE_STORAGE${CL} ${GN}for Template Storage." +# DEFAULT_FILE="/usr/local/community-scripts/default_storage" +# if [[ -f "$DEFAULT_FILE" ]]; then +# source "$DEFAULT_FILE" +# if [[ -n "$TEMPLATE_STORAGE" && -n "$CONTAINER_STORAGE" ]]; then +# msg_info "Using default storage configuration from: $DEFAULT_FILE" +# msg_ok "Template Storage: ${BL}$TEMPLATE_STORAGE${CL} ${GN}|${CL} Container Storage: ${BL}$CONTAINER_STORAGE${CL}" +# else +# msg_warn "Default storage file exists but is incomplete – falling back to manual selection" +# TEMPLATE_STORAGE=$(select_storage template) +# msg_ok "Using ${BL}$TEMPLATE_STORAGE${CL} ${GN}for Template Storage." +# CONTAINER_STORAGE=$(select_storage container) +# msg_ok "Using ${BL}$CONTAINER_STORAGE${CL} ${GN}for Container Storage." +# fi +# else +# # TEMPLATE STORAGE SELECTION +# # Template Storage +# while true; do +# TEMPLATE_STORAGE=$(select_storage template) +# if [[ -n "$TEMPLATE_STORAGE" ]]; then +# msg_ok "Using ${BL}$TEMPLATE_STORAGE${CL} ${GN}for Template Storage." +# break +# fi +# msg_warn "No valid template storage selected. Please try again." +# done -# Get container storage -CONTAINER_STORAGE=$(select_storage container) -msg_ok "Using ${BL}$CONTAINER_STORAGE${CL} ${GN}for Container Storage." +# while true; do +# CONTAINER_STORAGE=$(select_storage container) +# if [[ -n "$CONTAINER_STORAGE" ]]; then +# msg_ok "Using ${BL}$CONTAINER_STORAGE${CL} ${GN}for Container Storage." +# break +# fi +# msg_warn "No valid container storage selected. Please try again." +# done + +# fi while true; do if select_storage template; then @@ -202,6 +230,7 @@ while true; do break fi done + # Check free space on selected container storage STORAGE_FREE=$(pvesm status | awk -v s="$CONTAINER_STORAGE" '$1 == s { print $6 }') REQUIRED_KB=$((${PCT_DISK_SIZE:-8} * 1024 * 1024)) @@ -269,8 +298,6 @@ if ! pveam list "$TEMPLATE_STORAGE" | grep -q "$TEMPLATE" || ! zstdcat "$TEMPLAT done 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