testing: default_storage

This commit is contained in:
CanbiZ 2025-06-25 14:40:17 +02:00
parent 4ba64a0348
commit 4b4913ab3e
2 changed files with 53 additions and 12 deletions

View File

@ -185,6 +185,31 @@ ssh_check() {
fi fi
fi fi
} }
manage_default_storage() {
local current_template="None"
local current_container="None"
local file="/usr/local/community-scripts/default_storage"
if [[ -f "$file" ]]; then
source "$file"
current_template="$TEMPLATE_STORAGE"
current_container="$CONTAINER_STORAGE"
fi
local tmpl=$(select_storage template)
local cont=$(select_storage container)
mkdir -p /usr/local/community-scripts
cat <<EOF >"$file"
TEMPLATE_STORAGE=$tmpl
CONTAINER_STORAGE=$cont
EOF
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
--msgbox "Default Storage set:\n\nTemplate: $tmpl\nContainer: $cont" 10 58
}
base_settings() { base_settings() {
# Default Settings # Default Settings
CT_TYPE="1" CT_TYPE="1"
@ -884,13 +909,14 @@ install_script() {
while true; do while true; do
CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "SETTINGS" --menu "Choose an option:" \ CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "SETTINGS" --menu "Choose an option:" \
18 60 6 \ 20 60 7 \
"1" "Default Settings" \ "1" "Default Settings" \
"2" "Default Settings (with verbose)" \ "2" "Default Settings (with verbose)" \
"3" "Advanced Settings" \ "3" "Advanced Settings" \
"4" "Use Config File" \ "4" "Use Config File" \
"5" "Diagnostic Settings" \ "5" "Manage Default Storage" \
"6" "Exit" --nocancel --default-item "1" 3>&1 1>&2 2>&3) "6" "Diagnostic Settings" \
"7" "Exit" --nocancel --default-item "1" 3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "${CROSS}${RD} Menu canceled. Exiting.${CL}" echo -e "${CROSS}${RD} Menu canceled. Exiting.${CL}"
@ -932,7 +958,11 @@ install_script() {
config_file config_file
break break
;; ;;
5) 5)
manage_default_storage
;;
6)
if [[ $DIAGNOSTICS == "yes" ]]; then if [[ $DIAGNOSTICS == "yes" ]]; then
if whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "DIAGNOSTICS SETTINGS" --yesno "Send Diagnostics of LXC Installation?\n\nCurrent setting: ${DIAGNOSTICS}" 10 58 \ if whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "DIAGNOSTICS SETTINGS" --yesno "Send Diagnostics of LXC Installation?\n\nCurrent setting: ${DIAGNOSTICS}" 10 58 \
--yes-button "No" --no-button "Back"; then --yes-button "No" --no-button "Back"; then
@ -948,9 +978,8 @@ install_script() {
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "DIAGNOSTICS SETTINGS" --msgbox "Diagnostics settings changed to ${DIAGNOSTICS}." 8 58 whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "DIAGNOSTICS SETTINGS" --msgbox "Diagnostics settings changed to ${DIAGNOSTICS}." 8 58
fi fi
fi fi
;; ;;
6) 7)
echo -e "${CROSS}${RD}Exiting.${CL}" echo -e "${CROSS}${RD}Exiting.${CL}"
exit 0 exit 0
;; ;;

View File

@ -158,13 +158,25 @@ if qm status "$CTID" &>/dev/null || pct status "$CTID" &>/dev/null; then
exit 206 exit 206
fi fi
# Get template storage DEFAULT_FILE="/usr/local/community-scripts/default_storage"
TEMPLATE_STORAGE=$(select_storage template) if [[ -f "$DEFAULT_FILE" ]]; then
msg_ok "Using ${BL}$TEMPLATE_STORAGE${CL} ${GN}for Template Storage." source "$DEFAULT_FILE"
if [[ -n "$TEMPLATE_STORAGE" && -n "$CONTAINER_STORAGE" ]]; then
# Get container storage msg_info "Using default storage configuration"
CONTAINER_STORAGE=$(select_storage container) msg_ok "Template Storage: ${BL}$TEMPLATE_STORAGE${CL} ${GN}|${CL} Container Storage: ${BL}$CONTAINER_STORAGE${CL}"
msg_ok "Using ${BL}$CONTAINER_STORAGE${CL} ${GN}for Container Storage." else
msg_warn "Default storage file found but 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=$(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
# Check free space on selected container storage # Check free space on selected container storage
STORAGE_FREE=$(pvesm status | awk -v s="$CONTAINER_STORAGE" '$1 == s { print $6 }') STORAGE_FREE=$(pvesm status | awk -v s="$CONTAINER_STORAGE" '$1 == s { print $6 }')