Skip to content

Commit b442948

Browse files
authored
fix: Use custom config file
Fix for #4
1 parent b5b2143 commit b442948

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

samba.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,17 @@ find / -path "$share" -prune -o -user "$OldUID" -exec chown -h "$USER" {} \;
3535
# Change Samba password
3636
echo -e "$PASS\n$PASS" | smbpasswd -a -s "$USER" || { echo "Failed to change Samba password for $USER"; exit 1; }
3737

38+
rm -f /etc/samba/smb.custom
39+
cp /etc/samba/smb.conf /etc/samba/smb.custom
40+
3841
# Update force user and force group in smb.conf
39-
sed -i "s/^\(\s*\)force user =.*/\1force user = $USER/" "/etc/samba/smb.conf"
40-
sed -i "s/^\(\s*\)force group =.*/\1force group = $group/" "/etc/samba/smb.conf"
42+
sed -i "s/^\(\s*\)force user =.*/\1force user = $USER/" "/etc/samba/smb.custom"
43+
sed -i "s/^\(\s*\)force group =.*/\1force group = $group/" "/etc/samba/smb.custom"
4144

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

4851
# Create shared directory and set permissions
@@ -55,4 +58,4 @@ chown -R "$USER:$group" "$share" || { echo "Failed to set ownership for director
5558
# --debug-stdout: Send debug output to stdout.
5659
# --debuglevel=1: Set debug verbosity level to 1.
5760
# --no-process-group: Don't create a new process group for the daemon.
58-
exec smbd --foreground --debug-stdout --debuglevel=1 --no-process-group
61+
exec smbd --config-file=/etc/samba/smb.custom --foreground --debug-stdout --debuglevel=1 --no-process-group

0 commit comments

Comments
 (0)