#!/bin/bash TMP_FILE=$(mktemp) TMP_USERS=$(mktemp) TMP_OUT=$(mktemp) # 1) Get the list of users bash $SMB_TOOLS_PATH/functions/list_smb_users.sh > "$TMP_USERS" if [ ! -s "$TMP_USERS" ]; then dialog --msgbox "No users" 10 40 rm -f "$TMP_FILE" "$TMP_USERS" "$TMP_OUT" exit 1 fi # 2) Prepare user list for dialog --menu (username + empty description) MENU_ITEMS=() while read -r user; do MENU_ITEMS+=("$user" "") done < "$TMP_USERS" # 3) Ask the user to select one from the list dialog --backtitle "Remove SMB User" \ --menu "Select a user to remove:" 15 50 8 \ "${MENU_ITEMS[@]}" 2>"$TMP_FILE" USERNAME=$(<"$TMP_FILE") # 4) Run the removal script bash $SMB_TOOLS_PATH/functions/remove_smb_user.sh "$USERNAME" >"$TMP_OUT" 2>&1 # 5) Show output dialog --backtitle "Remove SMB User" \ --title "Result" \ --textbox "$TMP_OUT" 20 60 # 6) Cleanup rm -f "$TMP_FILE" "$TMP_USERS" "$TMP_OUT"