[Samba] Samba4 Auto-start

Mike Ray mray at xes-inc.com
Thu Feb 21 09:23:17 MST 2013

Greg, Rick-- 

Thanks both for your suggestions. Here is how it finally ended up: 

As Greg thought, /usr/local/samba/sbin/samba as part of that upstart script was trying to use the default smb.conf (in /etc/samba) as opposed to the properly configured one in /usr/local/samba/etc. The solution here was simply removing the bad configuration and then symlink to the proper one. One lingering question here is why manually calling /usr/local/samba/sbin/samba (after the killall) used the correct configuration file automatically, but why it didn't do that magic when part of a script. 

However, at this point, it still wasn't up and running properly. After some group analysis, we believed it was the fact that bind9 was not yet started when Samba was starting (we have --dns-backend=BIND9_DLZ). After poking around to set up a proper dependency between bind9 and Samba4, it worked as expected. 

In case anyone else wants to set this up, here the files -- note please that this converts bind9 to an upstart minion, not a sysV relic; thus bind9 must be removed from the sysV start method. This can be achieved with "update-rc.d -f bind9 remove" . 

/etc/init/samba4.conf : 
#description "SMB/CIFS File and Active Directory Server" 
#author "Jelmer Vernooij <jelmer at ubuntu.com>" 
start on (local-filesystems and net-device-up and started bind9) 
stop on runlevel [!2345] 
expect fork 
normal exit 0 
pre-start script 
[ -r /etc/default/samba4 ] && . /etc/default/samba4 
install -o root -g root -m 755 -d /var/run/samba 
install -o root -g root -m 755 -d /var/log/samba 
end script 
exec /usr/local/samba/sbin/samba -D 

/etc/init/bind9.conf : 
start on runlevel [2345] 
stop on runlevel [!2345] 

pre-start script 
# dirs under /var/run can go away on reboots. 
mkdir -p /var/run/named 
chmod 775 /var/run/named 
chown root:bind /var/run/named >/dev/null 2>&1 || true 
end script 

#Add bind command-line options below 
exec /usr/sbin/named -f -u bind 

pre-stop exec rndc stop 

post-stop exec logger -p user.warning -t upstart-bind "bind stopped" 

respawn limit 3 10 
kill timeout 30 
console none 

Thanks much, 

----- Original Message -----

From: "Ricky Nance" <ricky.nance at weaubleau.k12.mo.us> 
To: "Greg Sloop" <gregs at sloop.net> 
Cc: "Mike Ray" <mray at xes-inc.com>, samba at lists.samba.org 
Sent: Wednesday, February 20, 2013 4:52:27 PM 
Subject: Re: [Samba] Samba4 Auto-start 

My bet is that smbd is spawning before your upstart script causing major problems. Try to issue a update-rc.d -f smbd remove then reboot and see if your problem goes away. 


On Wed, Feb 20, 2013 at 3:15 PM, Gregory Sloop < gregs at sloop.net > wrote: 

MR> I'll cut to the chase -- several weeks ago, I thought I had an 
MR> upstart configuration file that would start Samba4 when the VM was 
MR> turned on; but it turns out I was wrong. At the time there was 
MR> nothing on the wiki about it (the links were broken). 
MR> The script I thought was working was simply: 

MR> start on runlevel [2345] 
MR> exec /usr/local/samba/sbin/samba 

MR> In any case, looking at the official wiki today, I found a new 
MR> note, stating that the links were indeed broken and that this one should probably work: 


MR> I am running Version 4.1.0pre1-GIT-f25debf on Ubuntu 12.04 LTS, 
MR> with the samba executable at /usr/local/samba/sbin/samba and the 
MR> conf file as /etc/init/samba4.conf. 

I'm the one that dug up that upstart script and put it in the Wiki. 
[Since the link we broken.] 

But I don't think the upstart script has anything to do with what 
ports Samba's going to listen on. 

While someone else may be able to offer more helpful advice, I'd guess 
that the difference is that the upstart is starting samba with a 
different config than the manual start - if you figure out how it's 
getting a different config, then I suspect your problem will go away 
or be trivially solvable. 

Also, while I think there's no difference in terms of if the upstart 
script works properly or not, I used it on version 4.0.3. 

To unsubscribe from this list go to the following URL and read the 
instructions: https://lists.samba.org/mailman/options/samba 


More information about the samba mailing list