[Samba] Samba4 Auto-start

Mike Ray mray at xes-inc.com
Wed Feb 20 13:11:13 MST 2013


Hello all, 

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

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

In any case, looking at the official wiki today, I found a new note, stating that the links were indeed broken and that this one should probably work: 
description "SMB/CIFS File and Active Directory Server"
author      "Jelmer Vernooij <jelmer at ubuntu.com>"
start on (local-filesystems and net-device-up)
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 
However, I am finding that this is not the case. From what I can tell, the script is doing something, just not anything useful (highlights denote difference between boot with conf file versus without). 

[netstat -tulpn on boot] 
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 769/smbd 
tcp 0 0 10.52.2.91:53 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 900/sshd 
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 769/smbd 
tcp6 0 0 :::139 :::* LISTEN 769/smbd 
tcp6 0 0 :::53 :::* LISTEN 1076/named 
tcp6 0 0 :::22 :::* LISTEN 900/sshd 
tcp6 0 0 ::1:953 :::* LISTEN 1076/named 
tcp6 0 0 :::445 :::* LISTEN 769/smbd 

Moreover, it seems to actually break samba, as a manual invocation does not get it to a functioning state (clients complain of no logon server to service the request). 

[netstat -tulpn after /usr/local/samba/sbin/samba after boot ] 
tcp 0 0 0.0.0.0:135 0.0.0.0:* LISTEN 1765/samba 
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 769/smbd 
tcp 0 0 10.52.2.91:53 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 900/sshd 
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 769/smbd 
tcp 0 0 0.0.0.0:1024 0.0.0.0:* LISTEN 1765/samba 
tcp6 0 0 :::135 :::* LISTEN 1765/samba 
tcp6 0 0 :::139 :::* LISTEN 769/smbd 
tcp6 0 0 :::53 :::* LISTEN 1076/named 
tcp6 0 0 :::22 :::* LISTEN 900/sshd 
tcp6 0 0 ::1:953 :::* LISTEN 1076/named 
tcp6 0 0 :::445 :::* LISTEN 769/smbd 
tcp6 0 0 :::1024 :::* LISTEN 1765/samba 

However, killing it all and starting it cleanly gets it to a proper, functioning state (clients can log in, etc.). 

[netstat -tulpn after killall samba and /usr/local/samba/sbin/samba after the aforementioned] 
tcp 0 0 0.0.0.0:3268 0.0.0.0:* LISTEN 1805/samba 
tcp 0 0 0.0.0.0:3269 0.0.0.0:* LISTEN 1805/samba 
tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 1805/samba 
tcp 0 0 0.0.0.0:135 0.0.0.0:* LISTEN 1801/samba 
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1803/smbd 
tcp 0 0 0.0.0.0:464 0.0.0.0:* LISTEN 1807/samba 
tcp 0 0 10.52.2.91:53 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 900/sshd 
tcp 0 0 0.0.0.0:88 0.0.0.0:* LISTEN 1807/samba 
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1076/named 
tcp 0 0 0.0.0.0:636 0.0.0.0:* LISTEN 1805/samba 
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1803/smbd 
tcp 0 0 0.0.0.0:1024 0.0.0.0:* LISTEN 1801/samba 
tcp6 0 0 :::3268 :::* LISTEN 1805/samba 
tcp6 0 0 :::3269 :::* LISTEN 1805/samba 
tcp6 0 0 :::389 :::* LISTEN 1805/samba 
tcp6 0 0 :::135 :::* LISTEN 1801/samba 
tcp6 0 0 :::139 :::* LISTEN 1803/smbd 
tcp6 0 0 :::464 :::* LISTEN 1807/samba 
tcp6 0 0 :::53 :::* LISTEN 1076/named 
tcp6 0 0 :::22 :::* LISTEN 900/sshd 
tcp6 0 0 :::88 :::* LISTEN 1807/samba 
tcp6 0 0 ::1:953 :::* LISTEN 1076/named 
tcp6 0 0 :::636 :::* LISTEN 1805/samba 
tcp6 0 0 :::445 :::* LISTEN 1803/smbd 
tcp6 0 0 :::1024 :::* LISTEN 1801/samba 

Does anyone know what is going on here? And does anyone have a working script? 

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

Thanks much, 



More information about the samba mailing list