#!/bin/bash TMP_FILE=$(mktemp) TMP_OUT=$(mktemp) TMP_USERS=$(mktemp) # 1) Ask for share name dialog --backtitle "Create SMB share" --inputbox "Enter share name (folder path):" 10 50 2>"$TMP_FILE" SHARE_NAME=$(<"$TMP_FILE") # 2) Retrieve list of users from external script bash $SMB_TOOLS_PATH/functions/list_smb_users.sh > "$TMP_USERS" if [ ! -s "$TMP_USERS" ]; then dialog --msgbox "No users found by get_users_list.sh" 10 40 rm -f "$TMP_FILE" "$TMP_USERS" "$TMP_OUT" exit 1 fi # Format list for dialog menu: convert each username into a pair (tag + description) MENU_ITEMS=() while read -r user; do MENU_ITEMS+=("$user" "") # empty description done < "$TMP_USERS" # 3) Ask for username via a menu dialog --backtitle "Create SMB share" \ --menu "Select associated username:" 15 50 8 \ "${MENU_ITEMS[@]}" 2>"$TMP_FILE" USERNAME=$(<"$TMP_FILE") # 4) Call the external script to create the share bash $SMB_TOOLS_PATH/functions/create_user_share.sh "$SHARE_NAME" "$USERNAME" >"$TMP_OUT" 2>&1 # 5) Display the result dialog --backtitle "Create SMB share" \ --title "Result" \ --textbox "$TMP_OUT" 20 60 # 6) Cleanup rm -f "$TMP_FILE" "$TMP_USERS" "$TMP_OUT"