Skip to content

Commit

Permalink
feat: Option to change from RW to RO (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepramon authored Mar 29, 2024
1 parent 2186fe2 commit 17e3f47
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ENV USER "samba"
ENV PASS "secret"
ENV UID 1000
ENV GID 1000
ENV RW true

HEALTHCHECK --interval=60s --timeout=15s CMD smbclient -L \\localhost -U % -m SMB3

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
PASS: "secret"
UID: 1000 # Optional, default 1000
GID: 1000 # Optional, default 1000
RW: true # Optional, default true
ports:
- 445:445
volumes:
Expand Down
6 changes: 6 additions & 0 deletions samba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ echo -e "$PASS\n$PASS" | smbpasswd -a -s "$USER" || { echo "Failed to change Sam
sed -i "s/^\(\s*\)force user =.*/\1force user = $USER/" "/etc/samba/smb.conf"
sed -i "s/^\(\s*\)force group =.*/\1force group = $group/" "/etc/samba/smb.conf"

# Verify if the RW variable is not equal to true (indicating read-only mode) and adjust settings accordingly
if [[ "$RW" != "true" ]]; then
sed -i "s/^\(\s*\)writable =.*/\1writable = no/" "/etc/samba/smb.conf"
sed -i "s/^\(\s*\)read only =.*/\1read only = yes/" "/etc/samba/smb.conf"
fi

# Create shared directory and set permissions
mkdir -p "$share" || { echo "Failed to create directory $share"; exit 1; }
chmod -R 0770 "$share" || { echo "Failed to set permissions for directory $share"; exit 1; }
Expand Down

0 comments on commit 17e3f47

Please sign in to comment.