From 0f7c1ba47744fe3778986639149352e35765efc4 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 25 May 2025 16:14:55 +0000 Subject: [PATCH] fix --- filebrowser/removeusers.txt | 3 +++ functions/create_user_share.sh | 11 +++++++---- functions/list_smb_shares.sh | 2 +- functions/remove_share.sh | 7 ++++--- gui/dialog_share_remove.sh | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/filebrowser/removeusers.txt b/filebrowser/removeusers.txt index e69de29..6aba88d 100644 --- a/filebrowser/removeusers.txt +++ b/filebrowser/removeusers.txt @@ -0,0 +1,3 @@ +luca +aaaa +prova diff --git a/functions/create_user_share.sh b/functions/create_user_share.sh index 5334a6e..9db77ab 100755 --- a/functions/create_user_share.sh +++ b/functions/create_user_share.sh @@ -31,17 +31,20 @@ fi SHARE_NAME=$(basename "$FOLDER_PATH") # 4. Ensure shares.d directory exists -if [ ! -d "$SHARE_CONFIG_DIR" ]; then - mkdir -p "$SHARE_CONFIG_DIR" +if [ ! -d "$SHARE_CONFIG_DIR/$USERNAME" ]; then + mkdir -p "$SHARE_CONFIG_DIR/$USERNAME" fi +# Controllare che uerfolder esista + # 5. Create Samba share config file -SHARE_CONFIG_FILE="$SHARE_CONFIG_DIR/$SHARE_NAME.conf" +SHARE_CONFIG_FILE="$SHARE_CONFIG_DIR/$USERNAME/$SHARE_NAME.conf" +echo $SHARE_CONFIG_FILE if [ -f "$SHARE_CONFIG_FILE" ]; then echo "Warning: Share config already exists: $SHARE_CONFIG_FILE" else cat < "$SHARE_CONFIG_FILE" -[$SHARE_NAME] +[$USERNAME-$SHARE_NAME] path = $FOLDER_PATH valid users = $USERNAME read only = no diff --git a/functions/list_smb_shares.sh b/functions/list_smb_shares.sh index 1e03371..8a633a6 100755 --- a/functions/list_smb_shares.sh +++ b/functions/list_smb_shares.sh @@ -7,7 +7,7 @@ if [ "$#" -ne 1 ]; then fi USERNAME="$1" -SHARE_DIR="/etc/samba/shares.d" +SHARE_DIR="/etc/samba/shares.d/$USERNAME" # Loop through share config files for file in "$SHARE_DIR"/*.conf; do diff --git a/functions/remove_share.sh b/functions/remove_share.sh index 658c987..9866723 100755 --- a/functions/remove_share.sh +++ b/functions/remove_share.sh @@ -5,15 +5,16 @@ set -euo pipefail -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " exit 1 fi SHARE_NAME="$1" +USERNAME="$2" SHARE_CONFIG_DIR="/etc/samba/shares.d" SMBCONF="/etc/samba/smb.conf" -SHARE_CONFIG_FILE="$SHARE_CONFIG_DIR/$SHARE_NAME.conf" +SHARE_CONFIG_FILE="$SHARE_CONFIG_DIR/$USERNAME/$SHARE_NAME.conf" TRASH_BASE="$SMB_DATA_FOLDER/trash" # 1. Read the .conf file if it exists diff --git a/gui/dialog_share_remove.sh b/gui/dialog_share_remove.sh index ba2a8e7..22f281e 100755 --- a/gui/dialog_share_remove.sh +++ b/gui/dialog_share_remove.sh @@ -65,7 +65,7 @@ SHARE=$(<"$TMP_FILE") # Call the external script to create the share -bash $SMB_TOOLS_PATH/functions/remove_share.sh "$SHARE" >"$TMP_OUT" 2>&1 +bash $SMB_TOOLS_PATH/functions/remove_share.sh "$SHARE" "$USERNAME" >"$TMP_OUT" 2>&1 # Display the result dialog --backtitle "Remove SMB share" \