update menu shared

This commit is contained in:
MacRimi
2025-09-06 19:13:52 +02:00
parent e1b340966a
commit 9b7b271580
2 changed files with 33 additions and 57 deletions

View File

@@ -232,9 +232,8 @@ pmx_select_host_mount_point() {
local choice folder_name result existing_dirs mount_point local choice folder_name result existing_dirs mount_point
while true; do while true; do
choice=$(dialog --backtitle "ProxMenux" --title "$title" --menu "$(translate "Where do you want the host folder?")" 16 76 3 \ choice=$(dialog --backtitle "ProxMenux" --title "$title" --menu "\n$(translate "Where do you want the host folder?")" 16 76 3 \
"1" "$(translate "Create new folder in /mnt")" \ "1" "$(translate "Create new folder in /mnt")" \
"2" "$(translate "Use existing folder")" \
"3" "$(translate "Enter custom path")" 3>&1 1>&2 2>&3) || { echo ""; return 1; } "3" "$(translate "Enter custom path")" 3>&1 1>&2 2>&3) || { echo ""; return 1; }
case "$choice" in case "$choice" in
@@ -247,23 +246,6 @@ pmx_select_host_mount_point() {
;; ;;
2) 2)
existing_dirs=($(ls -1d /mnt/*/ 2>/dev/null | sed 's:/$::'))
if [[ ${#existing_dirs[@]} -eq 0 ]]; then
dialog --msgbox "$(translate "No existing folders found in /mnt")" 8 60
continue
fi
mount_point=$(dialog --backtitle "ProxMenux" --title "$(translate "Select Existing Folder")" \
--menu "$(translate "Choose a folder in /mnt:")" 20 70 10 \
$(for d in "${existing_dirs[@]}"; do echo "$d" "$(basename "$d")"; done) \
3>&1 1>&2 2>&3) || continue
if [[ "$context" =~ ^(nfs|samba)$ ]] && [[ -n "$(ls -A "$mount_point" 2>/dev/null)" ]]; then
dialog --backtitle "ProxMenux" --yesno "$(translate "Warning: The selected folder is not empty. Files may not be accessible once the network share is mounted. Proceed anyway?")" 12 70 || continue
fi
echo "$mount_point"; return 0
;;
3)
clear clear
result=$(whiptail --inputbox "$(translate "Enter full path:")" 10 80 "$default_path" --title "$(translate "Custom Path")" 3>&1 1>&2 2>&3) || { echo ""; return 1; } result=$(whiptail --inputbox "$(translate "Enter full path:")" 10 80 "$default_path" --title "$(translate "Custom Path")" 3>&1 1>&2 2>&3) || { echo ""; return 1; }
[[ -z "$result" ]] && continue [[ -z "$result" ]] && continue
@@ -279,12 +261,6 @@ pmx_select_host_mount_point() {
select_host_directory() { select_host_directory() {
local method choice result local method choice result

View File

@@ -52,7 +52,7 @@ discover_nfs_servers() {
if [[ -z "$SERVERS" ]]; then if [[ -z "$SERVERS" ]]; then
cleanup cleanup
dialog --backtitle "Proxmenux" --title "$(translate "No Servers Found")" --msgbox "$(translate "No NFS servers found on the network.")\n\n$(translate "You can add servers manually.")" 10 60 whiptail --title "$(translate "No Servers Found")" --msgbox "$(translate "No NFS servers found on the network.")\n\n$(translate "You can add servers manually.")" 10 60
return 1 return 1
fi fi
@@ -67,11 +67,11 @@ discover_nfs_servers() {
if [[ ${#OPTIONS[@]} -eq 0 ]]; then if [[ ${#OPTIONS[@]} -eq 0 ]]; then
cleanup cleanup
dialog --backtitle "Proxmenux" --title "$(translate "No Valid Servers")" --msgbox "$(translate "No accessible NFS servers found.")" 8 50 whiptail --title "$(translate "No Valid Servers")" --msgbox "$(translate "No accessible NFS servers found.")" 8 50
return 1 return 1
fi fi
msg_ok "$(translate "NFS servers detected")" msg_ok "$(translate "NFS servers detected")"
NFS_SERVER=$(dialog --backtitle "Proxmenux" --title "$(translate "Select NFS Server")" --menu "$(translate "Choose an NFS server:")" 20 80 10 "${OPTIONS[@]}" 3>&1 1>&2 2>&3) NFS_SERVER=$(whiptail --title "$(translate "Select NFS Server")" --menu "$(translate "Choose an NFS server:")" 20 80 10 "${OPTIONS[@]}" 3>&1 1>&2 2>&3)
[[ -n "$NFS_SERVER" ]] && return 0 || return 1 [[ -n "$NFS_SERVER" ]] && return 0 || return 1
} }
@@ -94,7 +94,7 @@ select_nfs_server() {
clear clear
RECENT=$(grep "nfs" /etc/fstab 2>/dev/null | awk '{print $1}' | cut -d: -f1 | sort -u || true) RECENT=$(grep "nfs" /etc/fstab 2>/dev/null | awk '{print $1}' | cut -d: -f1 | sort -u || true)
if [[ -z "$RECENT" ]]; then if [[ -z "$RECENT" ]]; then
dialog --backtitle "Proxmenux" --title "$(translate "No Recent Servers")" --msgbox "\n$(translate "No recent NFS servers found.")" 8 50 dialog --title "$(translate "No Recent Servers")" --msgbox "\n$(translate "No recent NFS servers found.")" 8 50
return 1 return 1
fi fi
@@ -103,7 +103,7 @@ select_nfs_server() {
[[ -n "$server" ]] && OPTIONS+=("$server" "$(translate "Recent NFS server")") [[ -n "$server" ]] && OPTIONS+=("$server" "$(translate "Recent NFS server")")
done <<< "$RECENT" done <<< "$RECENT"
NFS_SERVER=$(dialog --backtitle "Proxmenux" --title "$(translate "Recent NFS Servers")" --menu "$(translate "Choose a recent server:")" 20 70 10 "${OPTIONS[@]}" 3>&1 1>&2 2>&3) NFS_SERVER=$(whiptail --title "$(translate "Recent NFS Servers")" --menu "$(translate "Choose a recent server:")" 20 70 10 "${OPTIONS[@]}" 3>&1 1>&2 2>&3)
[[ -n "$NFS_SERVER" ]] && return 0 || return 1 [[ -n "$NFS_SERVER" ]] && return 0 || return 1
;; ;;
*) *)
@@ -115,21 +115,21 @@ select_nfs_server() {
select_nfs_export() { select_nfs_export() {
if ! which showmount >/dev/null 2>&1; then if ! which showmount >/dev/null 2>&1; then
dialog --backtitle "Proxmenux" --title "$(translate "NFS Client Error")" \ whiptail --title "$(translate "NFS Client Error")" \
--msgbox "$(translate "showmount command is not working properly.")\n\n$(translate "Please check the installation.")" \ --msgbox "$(translate "showmount command is not working properly.")\n\n$(translate "Please check the installation.")" \
10 60 10 60
return 1 return 1
fi fi
if ! ping -c 1 -W 3 "$NFS_SERVER" >/dev/null 2>&1; then if ! ping -c 1 -W 3 "$NFS_SERVER" >/dev/null 2>&1; then
dialog --backtitle "Proxmenux" --title "$(translate "Connection Error")" \ whiptail --title "$(translate "Connection Error")" \
--msgbox "$(translate "Cannot reach server") $NFS_SERVER\n\n$(translate "Please check:")\n• $(translate "Server IP/hostname is correct")\n• $(translate "Network connectivity")\n• $(translate "Server is online")" \ --msgbox "$(translate "Cannot reach server") $NFS_SERVER\n\n$(translate "Please check:")\n• $(translate "Server IP/hostname is correct")\n• $(translate "Network connectivity")\n• $(translate "Server is online")" \
12 70 12 70
return 1 return 1
fi fi
if ! nc -z -w 3 "$NFS_SERVER" 2049 2>/dev/null; then if ! nc -z -w 3 "$NFS_SERVER" 2049 2>/dev/null; then
dialog --backtitle "Proxmenux" --title "$(translate "NFS Port Error")" \ whiptail --title "$(translate "NFS Port Error")" \
--msgbox "$(translate "NFS port (2049) is not accessible on") $NFS_SERVER\n\n$(translate "Please check:")\n• $(translate "NFS server is running")\n• $(translate "Firewall settings")\n• $(translate "NFS service is enabled")" \ --msgbox "$(translate "NFS port (2049) is not accessible on") $NFS_SERVER\n\n$(translate "Please check:")\n• $(translate "NFS server is running")\n• $(translate "Firewall settings")\n• $(translate "NFS service is enabled")" \
12 70 12 70
return 1 return 1
@@ -142,11 +142,11 @@ select_nfs_export() {
ERROR_MSG=$(echo "$EXPORTS_OUTPUT" | grep -i "error\|failed\|denied" | head -1) ERROR_MSG=$(echo "$EXPORTS_OUTPUT" | grep -i "error\|failed\|denied" | head -1)
if echo "$EXPORTS_OUTPUT" | grep -qi "connection refused\|network unreachable"; then if echo "$EXPORTS_OUTPUT" | grep -qi "connection refused\|network unreachable"; then
dialog --backtitle "Proxmenux" --title "$(translate "Network Error")" \ whiptail --title "$(translate "Network Error")" \
--msgbox "$(translate "Network connection failed to") $NFS_SERVER\n\n$(translate "Error:"): $ERROR_MSG\n\n$(translate "Please check:")\n• $(translate "Server is running")\n• $(translate "Network connectivity")\n• $(translate "Firewall settings")" \ --msgbox "$(translate "Network connection failed to") $NFS_SERVER\n\n$(translate "Error:"): $ERROR_MSG\n\n$(translate "Please check:")\n• $(translate "Server is running")\n• $(translate "Network connectivity")\n• $(translate "Firewall settings")" \
14 80 14 80
else else
dialog --backtitle "Proxmenux" --title "$(translate "NFS Error")" \ whiptail --title "$(translate "NFS Error")" \
--msgbox "$(translate "Failed to connect to") $NFS_SERVER\n\n$(translate "Error:"): $ERROR_MSG" \ --msgbox "$(translate "Failed to connect to") $NFS_SERVER\n\n$(translate "Error:"): $ERROR_MSG" \
12 80 12 80
fi fi
@@ -156,11 +156,11 @@ select_nfs_export() {
EXPORTS=$(echo "$EXPORTS_OUTPUT" | tail -n +2 | awk '{print $1}' | grep -v "^$") EXPORTS=$(echo "$EXPORTS_OUTPUT" | tail -n +2 | awk '{print $1}' | grep -v "^$")
if [[ -z "$EXPORTS" ]]; then if [[ -z "$EXPORTS" ]]; then
dialog --backtitle "Proxmenux" --title "$(translate "No Exports Found")" \ whiptail --title "$(translate "No Exports Found")" \
--msgbox "$(translate "No exports found on server") $NFS_SERVER\n\n$(translate "Server response:")\n$(echo "$EXPORTS_OUTPUT" | head -10)\n\n$(translate "You can enter the export path manually.")" \ --msgbox "$(translate "No exports found on server") $NFS_SERVER\n\n$(translate "Server response:")\n$(echo "$EXPORTS_OUTPUT" | head -10)\n\n$(translate "You can enter the export path manually.")" \
16 80 16 80
NFS_EXPORT=$(dialog --backtitle "Proxmenux" --inputbox "$(translate "Enter NFS export path (e.g., /mnt/shared):")" 10 60 --title "$(translate "Export Path")" 3>&1 1>&2 2>&3) NFS_EXPORT=$(whiptail --inputbox "$(translate "Enter NFS export path (e.g., /mnt/shared):")" 10 60 --title "$(translate "Export Path")" 3>&1 1>&2 2>&3)
[[ -z "$NFS_EXPORT" ]] && return 1 [[ -z "$NFS_EXPORT" ]] && return 1
return 0 return 0
fi fi
@@ -179,15 +179,15 @@ select_nfs_export() {
done <<< "$EXPORTS" done <<< "$EXPORTS"
if [[ ${#OPTIONS[@]} -eq 0 ]]; then if [[ ${#OPTIONS[@]} -eq 0 ]]; then
dialog --backtitle "Proxmenux" --title "$(translate "No Available Exports")" \ whiptail --title "$(translate "No Available Exports")" \
--msgbox "$(translate "No accessible exports found.")\n\n$(translate "You can enter the export path manually.")" \ --msgbox "$(translate "No accessible exports found.")\n\n$(translate "You can enter the export path manually.")" \
10 70 10 70
NFS_EXPORT=$(dialog --backtitle "Proxmenux" --inputbox "$(translate "Enter NFS export path (e.g., /mnt/shared):")" 10 60 --title "$(translate "Export Path")" 3>&1 1>&2 2>&3) NFS_EXPORT=$(whiptail --inputbox "$(translate "Enter NFS export path (e.g., /mnt/shared):")" 10 60 --title "$(translate "Export Path")" 3>&1 1>&2 2>&3)
[[ -n "$NFS_EXPORT" ]] && return 0 || return 1 [[ -n "$NFS_EXPORT" ]] && return 0 || return 1
fi fi
NFS_EXPORT=$(dialog --backtitle "Proxmenux" --title "$(translate "Select NFS Export")" --menu "$(translate "Choose an export to mount:")" 20 70 10 "${OPTIONS[@]}" 3>&1 1>&2 2>&3) NFS_EXPORT=$(whiptail --title "$(translate "Select NFS Export")" --menu "$(translate "Choose an export to mount:")" 20 70 10 "${OPTIONS[@]}" 3>&1 1>&2 2>&3)
[[ -n "$NFS_EXPORT" ]] && return 0 || return 1 [[ -n "$NFS_EXPORT" ]] && return 0 || return 1
} }
@@ -203,7 +203,7 @@ select_host_mount_point() {
configure_host_mount_options() { configure_host_mount_options() {
MOUNT_TYPE=$(dialog --backtitle "Proxmenux" --title "$(translate "Mount Options")" --menu "$(translate "Select mount configuration:")" 15 70 4 \ MOUNT_TYPE=$(whiptail --title "$(translate "Mount Options")" --menu "$(translate "Select mount configuration:")" 15 70 4 \
"1" "$(translate "Default options read/write")" \ "1" "$(translate "Default options read/write")" \
"2" "$(translate "Read-only mount")" \ "2" "$(translate "Read-only mount")" \
"3" "$(translate "Enter custom options")" 3>&1 1>&2 2>&3) "3" "$(translate "Enter custom options")" 3>&1 1>&2 2>&3)
@@ -219,7 +219,7 @@ configure_host_mount_options() {
;; ;;
3) 3)
MOUNT_OPTIONS=$(dialog --backtitle "Proxmenux" --inputbox "$(translate "Enter custom mount options:")" \ MOUNT_OPTIONS=$(whiptail --inputbox "$(translate "Enter custom mount options:")" \
10 70 "rw,hard,nofail,rsize=131072,wsize=131072,timeo=600,retrans=2" \ 10 70 "rw,hard,nofail,rsize=131072,wsize=131072,timeo=600,retrans=2" \
--title "$(translate "Custom Options")" 3>&1 1>&2 2>&3) --title "$(translate "Custom Options")" 3>&1 1>&2 2>&3)
[[ $? -ne 0 ]] && return 1 [[ $? -ne 0 ]] && return 1
@@ -230,7 +230,7 @@ configure_host_mount_options() {
;; ;;
esac esac
if dialog --backtitle "Proxmenux" --yesno "$(translate "Do you want to make this mount permanent?")\n\n$(translate "This will add the mount to /etc/fstab so it persists after reboot.")" 10 70 --title "$(translate "Permanent Mount")"; then if whiptail --yesno "$(translate "Do you want to make this mount permanent?")\n\n$(translate "This will add the mount to /etc/fstab so it persists after reboot.")" 10 70 --title "$(translate "Permanent Mount")"; then
PERMANENT_MOUNT=true PERMANENT_MOUNT=true
else else
if [[ $? -eq 1 ]]; then if [[ $? -eq 1 ]]; then
@@ -255,14 +255,14 @@ configure_host_mount_options() {
msg_ok "$(translate "NFS export is accessible")" msg_ok "$(translate "NFS export is accessible")"
if dialog --backtitle "Proxmenux" --yesno "$(translate "Do you want to add this as Proxmox storage?")\n\n$(translate "This will make the NFS share available as storage in Proxmox web interface.")" 10 70 --title "$(translate "Proxmox Storage")"; then if whiptail --yesno "$(translate "Do you want to add this as Proxmox storage?")\n\n$(translate "This will make the NFS share available as storage in Proxmox web interface.")" 10 70 --title "$(translate "Proxmox Storage")"; then
PROXMOX_STORAGE=true PROXMOX_STORAGE=true
STORAGE_ID=$(dialog --backtitle "Proxmenux" --inputbox "$(translate "Enter storage ID for Proxmox:")" 10 60 "nfs-$(echo $NFS_SERVER | tr '.' '-')" --title "$(translate "Storage ID")" 3>&1 1>&2 2>&3) STORAGE_ID=$(whiptail --inputbox "$(translate "Enter storage ID for Proxmox:")" 10 60 "nfs-$(echo $NFS_SERVER | tr '.' '-')" --title "$(translate "Storage ID")" 3>&1 1>&2 2>&3)
STORAGE_ID_RESULT=$? STORAGE_ID_RESULT=$?
if [[ $STORAGE_ID_RESULT -ne 0 ]]; then if [[ $STORAGE_ID_RESULT -ne 0 ]]; then
if dialog --backtitle "Proxmenux" --yesno "$(translate "Storage ID input was cancelled.")\n\n$(translate "Do you want to continue without Proxmox storage integration?")" 10 70 --title "$(translate "Continue Without Storage")"; then if whiptail --yesno "$(translate "Storage ID input was cancelled.")\n\n$(translate "Do you want to continue without Proxmox storage integration?")" 10 70 --title "$(translate "Continue Without Storage")"; then
PROXMOX_STORAGE=false PROXMOX_STORAGE=false
else else
return 1 return 1
@@ -283,7 +283,7 @@ configure_host_mount_options() {
rmdir "$TEMP_MOUNT" 2>/dev/null || true rmdir "$TEMP_MOUNT" 2>/dev/null || true
msg_warn "$(translate "NFS export accessibility test failed")" msg_warn "$(translate "NFS export accessibility test failed")"
if dialog --backtitle "Proxmenux" --yesno "$(translate "The NFS export could not be validated for accessibility.")\n\n$(translate "This might be due to:")\n• $(translate "Network connectivity issues")\n• $(translate "Export permission restrictions")\n• $(translate "Firewall blocking access")\n\n$(translate "Do you want to continue mounting anyway?")\n$(translate "(Proxmox storage integration will be skipped)")" 16 80 --title "$(translate "Export Validation Failed")"; then if whiptail --yesno "$(translate "The NFS export could not be validated for accessibility.")\n\n$(translate "This might be due to:")\n• $(translate "Network connectivity issues")\n• $(translate "Export permission restrictions")\n• $(translate "Firewall blocking access")\n\n$(translate "Do you want to continue mounting anyway?")\n$(translate "(Proxmox storage integration will be skipped)")" 16 80 --title "$(translate "Export Validation Failed")"; then
PROXMOX_STORAGE=false PROXMOX_STORAGE=false
msg_info "$(translate "Continuing without Proxmox storage integration due to accessibility issues.")" msg_info "$(translate "Continuing without Proxmox storage integration due to accessibility issues.")"
sleep 2 sleep 2
@@ -329,10 +329,10 @@ add_proxmox_nfs_storage() {
msg_ok "$(translate "pvesm command found")" msg_ok "$(translate "pvesm command found")"
# Check if storage ID already exists
if pvesm status "$storage_id" >/dev/null 2>&1; then if pvesm status "$storage_id" >/dev/null 2>&1; then
msg_warn "$(translate "Storage ID already exists:") $storage_id" msg_warn "$(translate "Storage ID already exists:") $storage_id"
if ! dialod --backtitle "Proxmenux" --yesno "$(translate "Storage ID already exists. Do you want to remove and recreate it?")" 8 60 --title "$(translate "Storage Exists")"; then if ! whiptail --yesno "$(translate "Storage ID already exists. Do you want to remove and recreate it?")" 8 60 --title "$(translate "Storage Exists")"; then
return 0 return 0
fi fi
pvesm remove "$storage_id" 2>/dev/null || true pvesm remove "$storage_id" 2>/dev/null || true
@@ -342,7 +342,7 @@ add_proxmox_nfs_storage() {
msg_info "$(translate "Creating NFS storage (Proxmox will auto-detect optimal NFS version)...")" msg_info "$(translate "Creating NFS storage (Proxmox will auto-detect optimal NFS version)...")"
# Let Proxmox handle NFS version negotiation automatically
if pvesm_output=$(pvesm add nfs "$storage_id" \ if pvesm_output=$(pvesm add nfs "$storage_id" \
--server "$server" \ --server "$server" \
--export "$export" \ --export "$export" \
@@ -350,7 +350,7 @@ add_proxmox_nfs_storage() {
msg_ok "$(translate "NFS storage added successfully!")" msg_ok "$(translate "NFS storage added successfully!")"
# Get the actual NFS version that Proxmox negotiated
local nfs_version="Auto-negotiated" local nfs_version="Auto-negotiated"
if pvesm config "$storage_id" 2>/dev/null | grep -q "options.*vers="; then if pvesm config "$storage_id" 2>/dev/null | grep -q "options.*vers="; then
nfs_version="v$(pvesm config "$storage_id" | grep "options" | grep -o "vers=[0-9.]*" | cut -d= -f2)" nfs_version="v$(pvesm config "$storage_id" | grep "options" | grep -o "vers=[0-9.]*" | cut -d= -f2)"
@@ -380,7 +380,7 @@ prepare_host_directory() {
local mount_point="$1" local mount_point="$1"
if [[ "$SHARE_COMMON_LOADED" == "true" ]]; then if [[ "$SHARE_COMMON_LOADED" == "true" ]]; then
# Use common functions for advanced directory preparation
local group_name local group_name
group_name=$(pmx_choose_or_create_group "sharedfiles") group_name=$(pmx_choose_or_create_group "sharedfiles")
if [[ -n "$group_name" ]]; then if [[ -n "$group_name" ]]; then
@@ -396,6 +396,7 @@ prepare_host_directory() {
msg_warn "$(translate "Failed to use shared functions, using basic directory creation.")" msg_warn "$(translate "Failed to use shared functions, using basic directory creation.")"
fi fi
# Fallback: basic directory creation
if ! test -d "$mount_point"; then if ! test -d "$mount_point"; then
if mkdir -p "$mount_point"; then if mkdir -p "$mount_point"; then
msg_ok "$(translate "Mount point created on host.")" msg_ok "$(translate "Mount point created on host.")"
@@ -435,18 +436,18 @@ mount_host_nfs_share() {
# Step 4: # Step 4:
configure_host_mount_options || return configure_host_mount_options || return
show_proxmenux_logo
msg_title "$(translate "Mount NFS Share on Host")"
prepare_host_directory "$MOUNT_POINT" || return 1 prepare_host_directory "$MOUNT_POINT" || return 1
if mount | grep -q "$MOUNT_POINT"; then if mount | grep -q "$MOUNT_POINT"; then
msg_warn "$(translate "Something is already mounted at") $MOUNT_POINT" msg_warn "$(translate "Something is already mounted at") $MOUNT_POINT"
if ! dialog --yesno "$(translate "Do you want to unmount it first?")" 8 60 --title "$(translate "Already Mounted")"; then if ! whiptail --yesno "$(translate "Do you want to unmount it first?")" 8 60 --title "$(translate "Already Mounted")"; then
return return
fi fi
umount "$MOUNT_POINT" 2>/dev/null || true umount "$MOUNT_POINT" 2>/dev/null || true
fi fi
show_proxmenux_logo
msg_title "$(translate "Mount NFS Share on Host")"
NFS_PATH="$NFS_SERVER:$NFS_EXPORT" NFS_PATH="$NFS_SERVER:$NFS_EXPORT"
@@ -621,8 +622,7 @@ unmount_host_nfs_share() {
CONFIRMATION_MSG="$CONFIRMATION_MSG\n• $(translate "Remove mount point directory")" CONFIRMATION_MSG="$CONFIRMATION_MSG\n• $(translate "Remove mount point directory")"
if dialog --backtitle "ProxMenux" --yesno "$CONFIRMATION_MSG" 16 80 --title "$(translate "Confirm Unmount")"; then if whiptail --yesno "$CONFIRMATION_MSG" 16 80 --title "$(translate "Confirm Unmount")"; then
show_proxmenux_logo show_proxmenux_logo
msg_title "$(translate "Unmount NFS Share from Host")" msg_title "$(translate "Unmount NFS Share from Host")"