From b3d2efe0b013f93528d1c88c40390a4d6289efbf Mon Sep 17 00:00:00 2001 From: arnydo Date: Fri, 15 Feb 2019 16:19:12 -0500 Subject: [PATCH] Add doc on running davmail as systemd service --- docs/index.rst | 85 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 20f40a7..462839a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1023,6 +1023,89 @@ To check the status of the service, run: .. code-block:: bash journalctl -u parsedmarc.service -r + +Running DavMail as a systemd service +--------------------------------------- + +Use systemd to run ``davmail`` as a service and process reports as they +arrive. + + +Create a system user + +.. code-block:: bash + + sudo useradd davmail -r -s /bin/false + +Protect the ``davmail`` configuration file from prying eyes + +.. code-block:: bash + + sudo chown root:parsedmarc /opt/davmail/davmail.properties + sudo chmod u=rw,g=r,o= /opt/davmail/davmail.properties + +Create the service configuration file + +.. code-block:: bash + + sudo nano /etc/systemd/system/davmail.service + +.. code-block:: ini + + [Unit] + Description=DavMail gateway service + Documentation=https://sourceforge.net/projects/davmail/ + Wants=network-online.target + After=syslog.target network.target + + [Service] + ExecStart=/opt/davmail/davmail /opt/davmail/davmail.properties + User=davmail + Group=davmail + Restart=always + RestartSec=5m + + [Install] + WantedBy=multi-user.target + +Then, enable the service + +.. code-block:: bash + + sudo systemctl daemon-reload + sudo systemctl enable parsedmarc.service + sudo service davmail restart + +.. note:: + + You must also run the above commands whenever you edit + ``davmail.service``. + +.. warning:: + + Always restart the service every time you upgrade to a new version of + ``davmail``: + + .. code-block:: bash + + sudo service davmail restart + +To check the status of the service, run: + +.. code-block:: bash + + service davmail status + +.. note:: + + In the event of a crash, systemd will restart the service after 10 minutes, + but the `service davmail status` command will only show the logs for the + current process. To vew the logs for previous runs as well as the + current process (newest to oldest), run: + + .. code-block:: bash + + journalctl -u davmail.service -r Using the Kibana dashboards @@ -1282,4 +1365,4 @@ Indices and tables .. _XML files: https://github.com/domainaware/parsedmarc/tree/master/splunk -.. _LISTSERV 16.0-2017a: https://www.lsoft.com/news/dmarc-issue1-2018.asp \ No newline at end of file +.. _LISTSERV 16.0-2017a: https://www.lsoft.com/news/dmarc-issue1-2018.asp