Update build.func
This commit is contained in:
parent
7cbcff6af6
commit
7be780b25b
@ -186,6 +186,76 @@ 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
|
||||
|
||||
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')
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user