Skip to content

Commit eb8775b

Browse files
authored
Support more shared directories
Control the sharing of more directories through environment variables instead of hard-coding more shared directories
1 parent 57193b0 commit eb8775b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/samba.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ share="/data"
8686

8787
addShare "$share" "Data" "Shared" || error "Failed to create shared folder!"
8888

89-
[ -d "/data2" ] && addShare "/data2" "Data2" "Shared"
90-
[ -d "/data3" ] && addShare "/data3" "Data3" "Shared"
89+
IFS=',' read -r -a dirs <<< "${SHARED_DIRS:-}"
90+
# Traverse the directory and create shares
91+
for dir in "${dirs[@]}"; do
92+
if [ -d "$dir" ]; then
93+
dir_name=$(basename "$dir")
94+
addShare "$dir" "$dir_name" "Shared $dir_name" || error "Failed to create shared folder for $dir!"
95+
fi
96+
done
9197

9298
if ! smbd; then
9399
error "Samba daemon failed to start!"

0 commit comments

Comments
 (0)