Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HOWTO] Customize SMB.conf
#1
Information 
I dislike that a shared folder (“Backup” in my case) is added to the SMB.conf when I only want it to be available as a NFS share.  Windows 10 doesn't want to mount a NFS location if the same location is a SMB share.  After a lot of research and trial and error I came up with the below solution.  It's the accumulation of information from multiple different sources (all notated) and modified to fit my needs.  I thought it might be helpful to have it together in one thread.  Please feel free to ask questions.

Sources:
Code to force the META startup to run in the backgroup: MrPete
I had a heck of a time finding the META module.  Thanks goes to outkastm for it’s development.  META allows you to create startup and/or shutdown scripts for your NAS.

First, I installed the META module.  Be sure to enable it.

Next, I loaded my existing smb.conf.

Code:
vi /var/run/smb.conf

I copied it’s contents to my favorite editor and removed the offending block - [Backup] in my case.

Now I needed someplace to keep my new modified SMB configuration file, so I created a directory under modules and named it SMB

Code:
mkdir /raid/data/module/SMB

I then created what would be my smb.conf template

Code:
vi /raid/data/module/SMB/smb.new

I pasted the modified smb.conf contents into the new files and closed the file after saving the changes.

Next we need to create the script that will actually replace the existing smb.conf with our new smb.conf everytime the NAS is booted.

Code:
vi /raid/data/module/META/system/etc/startup/smb.sh

This file will contain the following code:

Code:
#!/bin/bash
# Thanks to MrPete for the base code

echo "Starting SMBfix in background"

((smbargs=$#))

# Thecus system startup gives this script an argument (always "start"). I use that as a flag to know if I need to wait for smbd to start before editing anything.
# Here I declare a shell function to do all the work. Once it is declared, I will run it in the background down below.
# Then (once the background task is running) we immediately exit this script so the startup can continue.

SMBfixbg()
 {
   smbconf=/var/run/smb.conf

   if [ $smbargs -gt 0 ]
   then

       ((isleep = 0))
       echo "Waiting for Samba up to 100 sec" >>/raid/module/META/system/etc/startup.log
       while ! ps | grep -v grep | grep smbd &>/dev/null ; do
           sleep 1
           ((isleep++))
           if [ $isleep -gt 100 ]
           then
             break
           fi
       done
       echo "Took $isleep seconds for Samba to start" >>/raid/module/META/system/etc/startup.log
   fi

# make sure everything is quiet
   sleep 3

# replace existing smb.conf with mine
   cp /raid/data/module/SMB/smb.new /var/run/smb.conf

# restart samba so it loads the new conf

   killall smbd
   killall nmbd

   /opt/samba/sbin/smbd -D
   /opt/samba/sbin/nmbd -D

   date >>/raid/module/META/system/etc/startup.log
   echo "SMBfix done" >>/raid/module/META/system/etc/startup.log
 }

 SMBfixbg &

exit 0

Save and close the file and then make it executable

Code:
chmod +x smb.sh

You can manually call the script to make sure it actually replaces the conf file.

Code:
bash  /raid/data/module/META/system/etc/startup/smb.sh


Assuming the existing conf now mirrors the custom conf, you can reboot to ensure META does it's job.


This is a great thread on why all of this is necessary: Linky

META release thread: META  Direct META Download: Here

Another thread that provided some additional information: Linky

My system specs: N5550 with OS5 and firmware 2.06.02.6.cdv.





Search Tags: Meta Module, SMB, Samba, smb.conf, smb.cfg, shared folder, startup script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)