@@ -35,14 +35,17 @@ find / -path "$share" -prune -o -user "$OldUID" -exec chown -h "$USER" {} \;
35
35
# Change Samba password
36
36
echo -e " $PASS \n$PASS " | smbpasswd -a -s " $USER " || { echo " Failed to change Samba password for $USER " ; exit 1; }
37
37
38
+ rm -f /etc/samba/smb.custom
39
+ cp /etc/samba/smb.conf /etc/samba/smb.custom
40
+
38
41
# 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 "
41
44
42
45
# Verify if the RW variable is not equal to true (indicating read-only mode) and adjust settings accordingly
43
46
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 "
46
49
fi
47
50
48
51
# Create shared directory and set permissions
@@ -55,4 +58,4 @@ chown -R "$USER:$group" "$share" || { echo "Failed to set ownership for director
55
58
# --debug-stdout: Send debug output to stdout.
56
59
# --debuglevel=1: Set debug verbosity level to 1.
57
60
# --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