diff --git a/scripts/vm/select_linux_iso.sh b/scripts/vm/select_linux_iso.sh index af257c3..6bf0c13 100644 --- a/scripts/vm/select_linux_iso.sh +++ b/scripts/vm/select_linux_iso.sh @@ -173,6 +173,7 @@ function select_linux_custom_iso() { done < <(find "$ISO_DIR" -type f -iname "*.iso" | sort) if [[ ${#ISO_LIST[@]} -eq 0 ]]; then + header_info msg_error "$(translate "No ISO images found in $ISO_DIR.")" sleep 2 return 1 @@ -183,6 +184,7 @@ function select_linux_custom_iso() { "${ISO_LIST[@]}" 3>&1 1>&2 2>&3) if [[ -z "$ISO_FILE" ]]; then + header_info msg_warn "$(translate "No ISO selected.")" return 1 fi diff --git a/scripts/vm/select_windows_iso.sh b/scripts/vm/select_windows_iso.sh index e66b2b1..20db272 100644 --- a/scripts/vm/select_windows_iso.sh +++ b/scripts/vm/select_windows_iso.sh @@ -70,6 +70,8 @@ function select_existing_iso() { ISO_NAME="$ISO_FILE" export ISO_PATH ISO_FILE ISO_NAME + export OS_TYPE="windows" + return 0 } @@ -86,5 +88,7 @@ function detect_latest_iso_created() { ISO_PATH="$ISO_FILE" export ISO_PATH ISO_FILE ISO_NAME + export OS_TYPE="windows" + return 0 } diff --git a/scripts/vm/vm_creator.sh b/scripts/vm/vm_creator.sh index bcc283e..f7f7693 100644 --- a/scripts/vm/vm_creator.sh +++ b/scripts/vm/vm_creator.sh @@ -173,6 +173,37 @@ function create_vm() { + + # Añadir TPM si es Windows + if [[ "$OS_TYPE" == "windows" ]]; then + msg_info "$(translate "Configuring TPM device")" + TPM_STORAGE=$(select_efi_storage "$VMID") + TPM_NAME="vm-${VMID}-tpmstate" + + STORAGE_TYPE=$(pvesm status -storage "$TPM_STORAGE" | awk 'NR>1 {print $2}') + case "$STORAGE_TYPE" in + nfs | dir) + TPM_EXT=".raw" + TPM_REF="$VMID/" + ;; + *) + TPM_EXT="" + TPM_REF="" + ;; + esac + + if pvesm alloc "$TPM_STORAGE" "$VMID" "$TPM_NAME$TPM_EXT" 4M >/dev/null 2>&1; then + qm set "$VMID" -tpmstate0 "$TPM_STORAGE:${TPM_REF}${TPM_NAME}${TPM_EXT},version=2.0" >/dev/null 2>&1 + qm set "$VMID" -tpmdev "tpm-tis" >/dev/null 2>&1 + msg_ok "$(translate "TPM device added to VM")" + else + msg_warn "$(translate "Failed to add TPM device.")" + fi + fi + + + + # ========================================================== # Crear discos virtuales o físicos con interfaz seleccionada # ==========================================================