Update menu help and info

This commit is contained in:
MacRimi 2025-05-06 20:42:12 +02:00
parent d93759d31a
commit 2f81ed14fb
3 changed files with 144 additions and 63 deletions

View File

@ -272,6 +272,7 @@ show_storage_commands() {
echo -e "20) ${GREEN}pvesm scan <storage>${NC} - $(translate 'Scan storage for new content')" echo -e "20) ${GREEN}pvesm scan <storage>${NC} - $(translate 'Scan storage for new content')"
echo -e "21) ${GREEN}qm importdisk <vmid> <img> <storage>${NC} - $(translate 'Import disk image to VM')" echo -e "21) ${GREEN}qm importdisk <vmid> <img> <storage>${NC} - $(translate 'Import disk image to VM')"
echo -e "22) ${GREEN}qm set <vmid> -<bus><index> <disk>${NC} - $(translate 'Add physical disk to VM via') passthrough" echo -e "22) ${GREEN}qm set <vmid> -<bus><index> <disk>${NC} - $(translate 'Add physical disk to VM via') passthrough"
echo -e "23) ${GREEN}qemu-img convert -O <format> <input> <output>${NC} - $(translate 'Convert disk image format')"
echo -e " ${DEF}0) $(translate ' Back to previous menu or Esc + Enter')" echo -e " ${DEF}0) $(translate ' Back to previous menu or Esc + Enter')"
echo echo
echo -en "${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter a number, or write or paste a command: ') ${CL}" echo -en "${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter a number, or write or paste a command: ') ${CL}"
@ -341,7 +342,37 @@ show_storage_commands() {
echo -en "\n${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter target storage name (e.g., local-lvm): ')${CL}" echo -en "\n${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter target storage name (e.g., local-lvm): ')${CL}"
read -r storage read -r storage
cmd="qm importdisk $vmid $image_path $storage" cmd1="qm importdisk $vmid $image_path $storage"
bash -c "$cmd1"
echo
disk_name=$(basename "$image_path")
imported_volume="${storage}:vm-${vmid}-disk-0"
echo -e "\n${YELLOW}$(translate 'Select disk interface type:')${NC}"
echo " 1) sata"
echo " 2) scsi"
echo " 3) virtio"
echo " 4) ide"
echo -en "${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter the number or type the interface name: ')${CL}"
read -r iface_type
case "$iface_type" in
1) iface="sata" ;;
2) iface="scsi" ;;
3) iface="virtio" ;;
4) iface="ide" ;;
*) iface="sata" ;;
esac
index=$(qm config "$vmid" | grep -oP "$iface\d+" | awk -F"$iface" '{print $2}' | sort -n | tail -n1)
index=$((index + 1))
echo -e "\n${YELLOW}$(translate 'Assigning imported disk to VM using the generated command')${NC}"
sleep 1
echo
echo -e "\n${GREEN}> $cmd1${NC}\n"
cmd="qm set $vmid -$iface$index $imported_volume"
;; ;;
22) 22)
echo -en "${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter VM ID: ')${CL}" echo -en "${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter VM ID: ')${CL}"
@ -388,10 +419,42 @@ show_storage_commands() {
sleep 1 sleep 1
cmd="qm set $vmid -$iface$index $disk_path" cmd="qm set $vmid -$iface$index $disk_path"
echo -e "\n${GREEN}> $cmd${NC}\n" ;;
bash -c "$cmd" 23)
echo -e "\n${YELLOW}$(translate 'Convert disk image format using QEMU-IMG')${NC}"
sleep 1
unset cmd echo -e "\n${YELLOW}$(translate 'Available images in /var/lib/vz/images/:')${NC}"
images=$(find /var/lib/vz/images/ -type f \( -iname "*.img" -o -iname "*.qcow2" -o -iname "*.vmdk" -o -iname "*.raw" -o -iname "*.vdi" -o -iname "*.vpc" -o -iname "*.qed" \))
if [[ -z "$images" ]]; then
echo -e "${RED}$(translate 'No disk images found in /var/lib/vz/images/. Please add an image first.')${NC}"
echo
msg_success "$(translate 'Press ENTER to return to the menu...')"
read -r
continue
else
echo "$images"
fi
echo -en "\n${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter full path to the input image (e.g., /var/lib/vz/images/disk.vmdk): ')${CL}"
read -r input_image
echo -e "\n${YELLOW}$(translate 'Available output formats include:')${NC} qcow2, raw, qed"
echo -en "\n${TAB}${BOLD}${YW}${HOLD}$(translate 'Enter the full path to the output image (e.g., /var/lib/vz/images/output.qcow2): ')${CL}"
read -r output_image
valid_formats=("qcow2" "raw" "qed")
output_format=$(echo "$output_image" | awk -F. '{print tolower($NF)}')
if ! [[ " ${valid_formats[*]} " =~ " ${output_format} " ]]; then
echo -e "\n${RED}$(translate 'Unsupported output format:') .$output_format${NC}"
msg_success "$(translate 'Press ENTER to return...')"
read -r
continue
fi
echo -e "\n${YELLOW}$(translate 'Converting image using command:')${NC}"
cmd="qemu-img convert -O $output_format $input_image $output_image"
;; ;;
0) break ;; 0) break ;;
*) cmd="$user_input" ;; *) cmd="$user_input" ;;

View File

@ -89,7 +89,7 @@ export default function HelpAndInfoPage() {
<p className="text-black"> <p className="text-black">
Each category contains carefully selected commands with descriptions, making it easier to find exactly what Each category contains commands with descriptions, making it easier to find exactly what
you need when you need it. This eliminates the need to remember complex command syntax or search through you need when you need it. This eliminates the need to remember complex command syntax or search through
documentation when performing administrative tasks. documentation when performing administrative tasks.
</p> </p>

View File

@ -52,6 +52,14 @@ export default function StorageCommandsPage() {
{ command: "pvesm scan <storage>", description: "Scan storage for new content" }, { command: "pvesm scan <storage>", description: "Scan storage for new content" },
], ],
}, },
{
title: "Disk Actions",
commands: [
{ command: "qm importdisk <vmid> <image_path> <storage>", description: "Attach disk image to VM" },
{ command: "qm set <vmid> -<bus><index> <disk_path>", description: "Assign physical disk to VM (passthrough mode)" },
{ command: "qemu-img convert -O <format> <input> <output>", description: "Convert disk image format)" },
],
},
] ]
return ( return (
@ -184,8 +192,18 @@ export default function StorageCommandsPage() {
<code className="bg-gray-100 px-1 py-0.5 rounded text-black">/path</code> with the directory you want to <code className="bg-gray-100 px-1 py-0.5 rounded text-black">/path</code> with the directory you want to
check check
</li> </li>
<li>
Replace placeholders like <code className="bg-gray-100 px-1 py-0.5 rounded text-black">&lt;vmid&gt;</code>,{" "}
<code className="bg-gray-100 px-1 py-0.5 rounded text-black">&lt;bus&gt;&lt;index&gt;</code>,{" "}
<code className="bg-gray-100 px-1 py-0.5 rounded text-black">&lt;disk&gt;</code>,{" "}
<code className="bg-gray-100 px-1 py-0.5 rounded text-black">&lt;format&gt;</code>,{" "}
<code className="bg-gray-100 px-1 py-0.5 rounded text-black">&lt;input&gt;</code> and{" "}
<code className="bg-gray-100 px-1 py-0.5 rounded text-black">&lt;output&gt;</code> with the actual values you
intend to use.
</li>
</ul> </ul>
</div> </div>
</div> </div>
) )
} }