From d9c7983bb5c203ec60cebc00fbfd50117f2d3d01 Mon Sep 17 00:00:00 2001 From: ncheng89 <48044818+ncheng89@users.noreply.github.com> Date: Wed, 8 Jan 2025 22:55:17 +0800 Subject: [PATCH] feat: Support more shared directories (#987) * Support more shared directories Control the sharing of more directories through environment variables instead of hard-coding more shared directories --- src/samba.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/samba.sh b/src/samba.sh index 7ef3d5a..e2c12c9 100644 --- a/src/samba.sh +++ b/src/samba.sh @@ -92,6 +92,13 @@ addShare "$share" "Data" "Shared" || error "Failed to create shared folder!" [ -d "/data2" ] && addShare "/data2" "Data2" "Shared" [ -d "/data3" ] && addShare "/data3" "Data3" "Shared" +IFS=',' read -r -a dirs <<< "${SHARES:-}" +for dir in "${dirs[@]}"; do + [ ! -d "$dir" ] && continue + dir_name=$(basename "$dir") + addShare "$dir" "$dir_name" "Shared $dir_name" || error "Failed to create shared folder for $dir!" +done + if ! smbd; then error "Samba daemon failed to start!" smbd -i --debug-stdout || true