Comment 7 for bug 596064

Revision history for this message
Abhishek Mukherjee (abhishek-s-mukherjee) wrote :

There is something interesting that happened after we changed the script the way you had described. NMBD started at boot. After some troubleshooting, we noticed the following errors in the /tmp/nmbd-upstart.log

$ cat /tmp/nmbd-upstart.log
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
ERROR: lock directory /var/run/samba does not exist
ERROR: pid directory /var/run/samba does not exist

This was only after we removed the date command, if I remember correctly. But the crux of the issue is that a race condition is stopping nmbd from starting. It so happens that samba and nmbd start up at the same time. The directory /var/run/samba is created by the samba service when its starting up. But samba service does that only after the command "testparm -s --parameter-name='disable netbios' 2>>/tmp/nmbd-upstart.log" has executed unsuccessfully. NMBD service stopped failing when we added date command in the script. The date command must have introduced the much needed delay which we couldn't introduce with the "sleep 20" command. However we created the directory before the execution of the "testparm" command execution and that fixed the issue. This race condition should ideally be avoided by forcing nmbd to start up only after samba service has started successfully. I don't know how to do that in an upstart script. Please guide.

At present the pre start section of the script looks like this -

pre-start script
# No need to keep it now
# date > /tmp/nmbd-upstart.log

# Introduced mkdir to fix race condition
 mkdir /var/run/samba
 NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' 2>/tmp/nmbd-upstart.log`
 [ "x$NMBD_DISABLED" = xYes ] && { stop; exit 0; }
 install -o root -g root -m 755 -d /var/run/samba
end script