@dazeb
Thank you for your great work.
But why not improve the script to sail around user imput errors?
Its easy to request the needed info from proxmox.
pvesm status
here is mine:
root@pve:/etc/pve/lxc# pvesm status
Name Type Status Total Used Available %
local dir disabled 0 0 0 N/A
local-btrfs btrfs active 487861252 366537424 118699936 75.13%
local-zPool dir active 3131481344 332993536 2798487808 10.63%
pvePool zfspool active 2827707936 29220018 2798487918 1.03%
This will list i.e. all storage names, types and state of storage.
Show the relevant infos as radio list and let the user select one of them.
No more input errors
Here is a simple script to make this happen
#!/bin/bash
# get all active storage names into an array
storage_Names=($(pvesm status | grep active | tr -s ' ' | cut -d ' ' -f1))
# get all active storage types into another array
storage_Types=($(pvesm status | grep active | tr -s ' ' | cut -d ' ' -f2))
# lets find how many names are in our array
storage_Count=${#storage_Names[@]}
# create a new arry for use with whiptail
storage_Array=()
I=1
for STORAGE in "${storage_Names[@]}"; do
storage_Array+=("$I" ":: $STORAGE " "off")
I=$(( I + 1 ))
done
# lets select a storage name
choice=""
while [ "$choice" == "" ]
do
choice=$(whiptail --title "DietPi Installation" --radiolist "Select Storage Pool" 20 50 $storage_Count "${storage_Array[@]}" 3>&1 1>&2 2>&3 )
done
# get name of choosen storage
Name=${storage_Names[$choice]}
echo 'Name: ' $Name
# get type of choosen storage
Type=${storage_Types[$choice]}
echo 'Typ: ' $Type
exit