test
This commit is contained in:
parent
a40041f875
commit
e2de55ac7a
154
misc/build.func
154
misc/build.func
@ -186,92 +186,92 @@ ssh_check() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
select_storage() {
|
# select_storage() {
|
||||||
local CLASS=$1 CONTENT CONTENT_LABEL
|
# local CLASS=$1 CONTENT CONTENT_LABEL
|
||||||
case $CLASS in
|
# case $CLASS in
|
||||||
container)
|
# container)
|
||||||
CONTENT='rootdir'
|
# CONTENT='rootdir'
|
||||||
CONTENT_LABEL='Container'
|
# CONTENT_LABEL='Container'
|
||||||
;;
|
# ;;
|
||||||
template)
|
# template)
|
||||||
CONTENT='vztmpl'
|
# CONTENT='vztmpl'
|
||||||
CONTENT_LABEL='Template'
|
# CONTENT_LABEL='Template'
|
||||||
;;
|
# ;;
|
||||||
iso)
|
# iso)
|
||||||
CONTENT='iso'
|
# CONTENT='iso'
|
||||||
CONTENT_LABEL='ISO image'
|
# CONTENT_LABEL='ISO image'
|
||||||
;;
|
# ;;
|
||||||
images)
|
# images)
|
||||||
CONTENT='images'
|
# CONTENT='images'
|
||||||
CONTENT_LABEL='VM Disk image'
|
# CONTENT_LABEL='VM Disk image'
|
||||||
;;
|
# ;;
|
||||||
backup)
|
# backup)
|
||||||
CONTENT='backup'
|
# CONTENT='backup'
|
||||||
CONTENT_LABEL='Backup'
|
# CONTENT_LABEL='Backup'
|
||||||
;;
|
# ;;
|
||||||
snippets)
|
# snippets)
|
||||||
CONTENT='snippets'
|
# CONTENT='snippets'
|
||||||
CONTENT_LABEL='Snippets'
|
# CONTENT_LABEL='Snippets'
|
||||||
;;
|
# ;;
|
||||||
*)
|
# *)
|
||||||
msg_error "Invalid storage class '$CLASS'."
|
# msg_error "Invalid storage class '$CLASS'."
|
||||||
exit 201
|
# exit 201
|
||||||
;;
|
# ;;
|
||||||
esac
|
# esac
|
||||||
|
|
||||||
command -v whiptail >/dev/null || {
|
# command -v whiptail >/dev/null || {
|
||||||
msg_error "whiptail missing."
|
# msg_error "whiptail missing."
|
||||||
exit 220
|
# exit 220
|
||||||
}
|
# }
|
||||||
command -v numfmt >/dev/null || {
|
# command -v numfmt >/dev/null || {
|
||||||
msg_error "numfmt missing."
|
# msg_error "numfmt missing."
|
||||||
exit 221
|
# exit 221
|
||||||
}
|
# }
|
||||||
|
|
||||||
local -a MENU
|
# local -a MENU
|
||||||
while read -r line; do
|
# while read -r line; do
|
||||||
local TAG=$(echo "$line" | awk '{print $1}')
|
# local TAG=$(echo "$line" | awk '{print $1}')
|
||||||
local TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
# 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}')
|
# 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")
|
# MENU+=("$TAG" "Type: $TYPE Free: $FREE" "OFF")
|
||||||
done < <(pvesm status -content "$CONTENT" | awk 'NR>1')
|
# done < <(pvesm status -content "$CONTENT" | awk 'NR>1')
|
||||||
|
|
||||||
if [ ${#MENU[@]} -eq 0 ]; then
|
# if [ ${#MENU[@]} -eq 0 ]; then
|
||||||
msg_error "No storage found for content type '$CONTENT'."
|
# msg_error "No storage found for content type '$CONTENT'."
|
||||||
exit 203
|
# exit 203
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
if [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
# if [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
echo "${MENU[0]}"
|
# echo "${MENU[0]}"
|
||||||
return
|
# return
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
local STORAGE
|
# local STORAGE
|
||||||
STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \
|
# STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool for ${CONTENT_LABEL,,}?\n(Spacebar to select)" \
|
# "Which storage pool for ${CONTENT_LABEL,,}?\n(Spacebar to select)" \
|
||||||
16 70 6 "${MENU[@]}" 3>&1 1>&2 2>&3) || {
|
# 16 70 6 "${MENU[@]}" 3>&1 1>&2 2>&3) || {
|
||||||
msg_error "Storage selection cancelled by user."
|
# msg_error "Storage selection cancelled by user."
|
||||||
exit 202
|
# exit 202
|
||||||
}
|
# }
|
||||||
echo "$STORAGE"
|
# echo "$STORAGE"
|
||||||
}
|
# }
|
||||||
|
|
||||||
manage_default_storage() {
|
# manage_default_storage() {
|
||||||
local file="/usr/local/community-scripts/default_storage"
|
# local file="/usr/local/community-scripts/default_storage"
|
||||||
mkdir -p /usr/local/community-scripts
|
# mkdir -p /usr/local/community-scripts
|
||||||
|
|
||||||
local tmpl=$(select_storage template)
|
# local tmpl=$(select_storage template)
|
||||||
local cont=$(select_storage container)
|
# local cont=$(select_storage container)
|
||||||
|
|
||||||
cat <<EOF >"$file"
|
# cat <<EOF >"$file"
|
||||||
TEMPLATE_STORAGE=$tmpl
|
# TEMPLATE_STORAGE=$tmpl
|
||||||
CONTAINER_STORAGE=$cont
|
# CONTAINER_STORAGE=$cont
|
||||||
EOF
|
# EOF
|
||||||
|
|
||||||
msg_ok "Default Storage set: Template=${BL}$tmpl${CL} ${GN}|${CL} Container=${BL}$cont${CL}"
|
# msg_ok "Default Storage set: Template=${BL}$tmpl${CL} ${GN}|${CL} Container=${BL}$cont${CL}"
|
||||||
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
|
# whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
|
||||||
--msgbox "Default Storage set:\n\nTemplate: $tmpl\nContainer: $cont" 10 58
|
# --msgbox "Default Storage set:\n\nTemplate: $tmpl\nContainer: $cont" 10 58
|
||||||
}
|
# }
|
||||||
|
|
||||||
base_settings() {
|
base_settings() {
|
||||||
# Default Settings
|
# Default Settings
|
||||||
|
@ -450,7 +450,7 @@ spinner() {
|
|||||||
msg_info() {
|
msg_info() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -ne " ${HOLD:-} ${YW}${msg} "
|
echo -ne " ${HOLD:-} ${YW}${msg} "
|
||||||
spinner
|
spinner &
|
||||||
SPINNER_PID=$!
|
SPINNER_PID=$!
|
||||||
echo "$SPINNER_PID" >/tmp/.spinner.pid
|
echo "$SPINNER_PID" >/tmp/.spinner.pid
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user