diff --git a/scripts/global/share-common.func b/scripts/global/share-common.func index adb8075..f014a25 100644 --- a/scripts/global/share-common.func +++ b/scripts/global/share-common.func @@ -265,7 +265,7 @@ pmx_select_host_mount_point() { -select_host_directory() { +select_host_directory_() { local method choice result method=$(whiptail --title "$(translate "Select Host Directory")" --menu "$(translate "How do you want to select the HOST folder to mount?")" 15 70 4 \ @@ -317,6 +317,60 @@ select_host_directory() { +select_host_directory() { + local method result + + + method=$(whiptail --title "$(translate "Select Host Directory")" \ + --menu "$(translate "How do you want to select the HOST folder to mount?")" 15 70 4 \ + "mnt" "$(translate "Select from /mnt directories")" \ + "manual" "$(translate "Enter path manually")" \ + 3>&1 1>&2 2>&3) || return 1 + + case "$method" in + mnt|srv|media) + local base_path="/$method" + local host_dirs=("$base_path"/*) + local options=() + + for dir in "${host_dirs[@]}"; do + [[ -d "$dir" ]] && options+=("$dir" "$(basename "$dir")") + done + + if [[ ${#options[@]} -eq 0 ]]; then + msg_error "$(translate "No directories found in") $base_path" + return 1 + fi + + result=$(whiptail --title "$(translate "Select Host Folder")" \ + --menu "$(translate "Select the folder to mount:")" 20 80 10 \ + "${options[@]}" 3>&1 1>&2 2>&3) || return 1 + ;; + manual) + result=$(whiptail --title "$(translate "Enter Path")" \ + --inputbox "$(translate "Enter the full path to the host folder:")" \ + 10 70 "/mnt/" 3>&1 1>&2 2>&3) || return 1 + ;; + *) + return 1 + ;; + esac + + [[ -z "$result" ]] && return 1 + [[ ! -d "$result" ]] && { + msg_error "$(translate "The selected path is not a valid directory:") $result" + return 1 + } + + echo "$result" + return 0 +} + + + + + + select_lxc_container() { local ct_list ctid ct_status