This commit is contained in:
CanbiZ 2025-06-30 10:38:29 +02:00
parent a40041f875
commit e2de55ac7a
2 changed files with 78 additions and 78 deletions

View File

@ -186,92 +186,92 @@ ssh_check() {
fi
}
select_storage() {
local CLASS=$1 CONTENT CONTENT_LABEL
case $CLASS in
container)
CONTENT='rootdir'
CONTENT_LABEL='Container'
;;
template)
CONTENT='vztmpl'
CONTENT_LABEL='Template'
;;
iso)
CONTENT='iso'
CONTENT_LABEL='ISO image'
;;
images)
CONTENT='images'
CONTENT_LABEL='VM Disk image'
;;
backup)
CONTENT='backup'
CONTENT_LABEL='Backup'
;;
snippets)
CONTENT='snippets'
CONTENT_LABEL='Snippets'
;;
*)
msg_error "Invalid storage class '$CLASS'."
exit 201
;;
esac
# select_storage() {
# local CLASS=$1 CONTENT CONTENT_LABEL
# case $CLASS in
# container)
# CONTENT='rootdir'
# CONTENT_LABEL='Container'
# ;;
# template)
# CONTENT='vztmpl'
# CONTENT_LABEL='Template'
# ;;
# iso)
# CONTENT='iso'
# CONTENT_LABEL='ISO image'
# ;;
# images)
# CONTENT='images'
# CONTENT_LABEL='VM Disk image'
# ;;
# backup)
# CONTENT='backup'
# CONTENT_LABEL='Backup'
# ;;
# snippets)
# CONTENT='snippets'
# CONTENT_LABEL='Snippets'
# ;;
# *)
# msg_error "Invalid storage class '$CLASS'."
# exit 201
# ;;
# esac
command -v whiptail >/dev/null || {
msg_error "whiptail missing."
exit 220
}
command -v numfmt >/dev/null || {
msg_error "numfmt missing."
exit 221
}
# command -v whiptail >/dev/null || {
# msg_error "whiptail missing."
# exit 220
# }
# command -v numfmt >/dev/null || {
# msg_error "numfmt missing."
# exit 221
# }
local -a MENU
while read -r line; do
local TAG=$(echo "$line" | awk '{print $1}')
local TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
local FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf "%9sB", $6}')
MENU+=("$TAG" "Type: $TYPE Free: $FREE" "OFF")
done < <(pvesm status -content "$CONTENT" | awk 'NR>1')
# local -a MENU
# while read -r line; do
# local TAG=$(echo "$line" | awk '{print $1}')
# local TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
# local FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf "%9sB", $6}')
# MENU+=("$TAG" "Type: $TYPE Free: $FREE" "OFF")
# done < <(pvesm status -content "$CONTENT" | awk 'NR>1')
if [ ${#MENU[@]} -eq 0 ]; then
msg_error "No storage found for content type '$CONTENT'."
exit 203
fi
# if [ ${#MENU[@]} -eq 0 ]; then
# msg_error "No storage found for content type '$CONTENT'."
# exit 203
# fi
if [ $((${#MENU[@]} / 3)) -eq 1 ]; then
echo "${MENU[0]}"
return
fi
# if [ $((${#MENU[@]} / 3)) -eq 1 ]; then
# echo "${MENU[0]}"
# return
# fi
local STORAGE
STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \
"Which storage pool for ${CONTENT_LABEL,,}?\n(Spacebar to select)" \
16 70 6 "${MENU[@]}" 3>&1 1>&2 2>&3) || {
msg_error "Storage selection cancelled by user."
exit 202
}
echo "$STORAGE"
}
# local STORAGE
# STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \
# "Which storage pool for ${CONTENT_LABEL,,}?\n(Spacebar to select)" \
# 16 70 6 "${MENU[@]}" 3>&1 1>&2 2>&3) || {
# msg_error "Storage selection cancelled by user."
# exit 202
# }
# echo "$STORAGE"
# }
manage_default_storage() {
local file="/usr/local/community-scripts/default_storage"
mkdir -p /usr/local/community-scripts
# manage_default_storage() {
# local file="/usr/local/community-scripts/default_storage"
# mkdir -p /usr/local/community-scripts
local tmpl=$(select_storage template)
local cont=$(select_storage container)
# local tmpl=$(select_storage template)
# local cont=$(select_storage container)
cat <<EOF >"$file"
TEMPLATE_STORAGE=$tmpl
CONTAINER_STORAGE=$cont
EOF
# cat <<EOF >"$file"
# TEMPLATE_STORAGE=$tmpl
# CONTAINER_STORAGE=$cont
# EOF
msg_ok "Default Storage set: Template=${BL}$tmpl${CL} ${GN}|${CL} Container=${BL}$cont${CL}"
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
--msgbox "Default Storage set:\n\nTemplate: $tmpl\nContainer: $cont" 10 58
}
# msg_ok "Default Storage set: Template=${BL}$tmpl${CL} ${GN}|${CL} Container=${BL}$cont${CL}"
# whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
# --msgbox "Default Storage set:\n\nTemplate: $tmpl\nContainer: $cont" 10 58
# }
base_settings() {
# Default Settings

View File

@ -450,7 +450,7 @@ spinner() {
msg_info() {
local msg="$1"
echo -ne " ${HOLD:-} ${YW}${msg} "
spinner
spinner &
SPINNER_PID=$!
echo "$SPINNER_PID" >/tmp/.spinner.pid
}