A samba-ad-dc.service file for Systemd

Today I found out that after rebooting my Samba4 DC based on Debian Jessie, systemd starts up smbd/nmbd/winbind again instead of samba-ad-dc. This has to stop, I want my domain back! So I dug around a bit and found that while there is an upstart config and an init script for samba-ad-dc, there is no systemd service file, so systemd just doesn't know what to do — the init script is nice enough to just go like "hey, I'mma call systemd for this!", which then goes to nirvana.

Since I couldn't find a systemd service definition file, I wrote one myself and put it into /etc/systemd/system/samba-ad-dc.service (the name is important, otherwise systemd won't find it correctly), yielding the following content:

Description=Samba4 AD DC
After=network.target remote-fs.target nss-lookup.target

ExecStart=/usr/sbin/samba -D


Then, I stopped the old daemons, updated the init sequence and started the AD DC again:

systemctl daemon-reload

systemctl stop smbd
systemctl stop nmbd
systemctl stop winbind
systemctl disable smbd
systemctl disable nmbd
systemctl disable winbind

systemctl enable samba-ad-dc
systemctl start samba-ad-dc

And finally, I have my AD back again!

If you're curious, I sent a bug report to Debian.