Last active
March 14, 2025 01:37
-
-
Save meetnick/fb5587d25d4174d7adbc8a1ded642d3c to your computer and use it in GitHub Desktop.
Add support to .conf files individually in samba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# default samba .conf file | |
SMB_CONF=/etc/samba/smb.conf | |
# samba directory to store samba configuration files individually | |
SMB_CONF_DIR=/etc/samba/smb.conf.d/ | |
# first need to create individual .conf files with desired sambs configuration into path defined above | |
# file which contains all includes to samba configuration files individually | |
SMB_INCLUDES=/etc/samba/includes.conf | |
# adds includes.conf file existance to smb.conf file | |
if ! grep -q 'include = '"${SMB_INCLUDES}" $SMB_CONF ; then | |
echo 'include = '"${SMB_INCLUDES}" | tee -a $SMB_CONF > /dev/null | |
fi | |
# create directory smb.conf.d to store samba .conf files | |
mkdir -p $SMB_CONF_DIR | |
# populates includes.conf with files in smb.conf.d directory | |
ls "${SMB_CONF_DIR}"* | sed -e 's/^/include = /' > $SMB_INCLUDES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
The above gist account that you have already conf files into directory
/etc/samba/smb.conf.d
./etc/samba/smb.conf.d/example.conf
Note: you can choose other conf files directory by changing env variable SMB_CONF_DIR.
The Gist automates the following:
include = /etc/samba/smb.conf.d/example.conf
Note: more entry must be appended (if needed) into includes.conf file.
include = /etc/samba/includes.conf