Difference between revisions of "Managing the Samba AD DC Service Using Systemd"

(Enabling and Disabling the Samba AD DC Service)
m (typo)
 
(2 intermediate revisions by one other user not shown)
Line 5: Line 5:
  
  
 +
== The <code>samba</code> Service ==
  
 +
On a DC, the <code>/usr/local/samba/sbin/samba</code> service automatically starts the required <code>smbd</code> and <code>winbindd</code> service as sub-processes. If you start them manually, the Samba DC fails to work as expected. If your package provider created additional Samba service files, disable and mask them to prevent that other services re-enable them. For example:
 +
 +
# systemctl mask smbd nmbd winbind
 +
# systemctl disable smbd nmbd winbind
 +
 +
For further details about permanently disabling services, see the <code>systemd</code> documentation.
  
 
= Creating the <code>systemd</code> Service File =
 
= Creating the <code>systemd</code> Service File =
Line 18: Line 25:
 
   
 
   
 
  [Service]
 
  [Service]
  Type=notify
+
  Type=forking
NotifyAccess=all
 
 
  ExecStart=/usr/local/samba/sbin/samba -D
 
  ExecStart=/usr/local/samba/sbin/samba -D
 
  PIDFile=/usr/local/samba/var/run/samba.pid
 
  PIDFile=/usr/local/samba/var/run/samba.pid
 
  ExecReload=/bin/kill -HUP $MAINPID
 
  ExecReload=/bin/kill -HUP $MAINPID
 
 
   
 
   
 
  [Install]
 
  [Install]
Line 33: Line 38:
  
 
  # systemctl daemon-reload
 
  # systemctl daemon-reload
 +
 +
 +
 +
  
 
= Managing the Samba AD DC Service =
 
= Managing the Samba AD DC Service =
Line 50: Line 59:
 
  # systemctl disable samba-ad-dc
 
  # systemctl disable samba-ad-dc
  
If you had Debian Samba installed before, make sure you purge the packages also, you can use the following commands to correct the systemd startup if you have problems to make sure this is correct.
 
# systemctl mask samba nmbd smbd winbind
 
# systemctl disable samba nmbd smbd winbind
 
  
Please not that winbind should not be started, this is handled by samba-ad-dc.
 
  
 
== Manually Starting and Stopping the Samba AD DC Service ==
 
== Manually Starting and Stopping the Samba AD DC Service ==

Latest revision as of 10:52, 6 November 2017

Introduction

The following describes how to use systemd to manage the Samba Active Directory (AD) domain controller (DC) service. For further details about systemd, see https://wiki.freedesktop.org/www/Software/systemd/.


The samba Service

On a DC, the /usr/local/samba/sbin/samba service automatically starts the required smbd and winbindd service as sub-processes. If you start them manually, the Samba DC fails to work as expected. If your package provider created additional Samba service files, disable and mask them to prevent that other services re-enable them. For example:

# systemctl mask smbd nmbd winbind
# systemctl disable smbd nmbd winbind

For further details about permanently disabling services, see the systemd documentation.

Creating the systemd Service File

Samba does not provide a systemd service file. When you built the Samba Active Directory (AD) domain controller (DC) from the sources, you must manually create the service file to enable systemd to manage the Samba AD DC service:

  • Create the /etc/systemd/system/samba-ad-dc.service file with the following content:
[Unit]
Description=Samba Active Directory Domain Controller
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/samba/sbin/samba -D
PIDFile=/usr/local/samba/var/run/samba.pid
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
For further details, see the systemd.service(5) man page.
  • Reload the systemd configuration:
# systemctl daemon-reload



Managing the Samba AD DC Service

The following assumes that the Samba Active Directory (AD) domain controller (DC) service is managed by the samba-ad-dc service file. If you have not created the service file manually, see your operating system's documentation for the name of the Samba AD DC service.


Enabling and Disabling the Samba AD DC Service

To enable the Samba Active Directory (AD) domain controller (DC) service to start automatically when the system boots, enter:

# systemctl enable samba-ad-dc

To disable the automatic start of the Samba AD DC service, enter:

# systemctl disable samba-ad-dc


Manually Starting and Stopping the Samba AD DC Service

To manually start the Samba Active Directory (AD) domain controller (DC) service, enter:

# systemctl start samba-ad-dc

To manually stop the Samba AD DC service, enter:

# systemctl stop samba-ad-dc