]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
dma: New package
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 12 Nov 2015 00:25:50 +0000 (00:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 12 Nov 2015 00:25:50 +0000 (00:25 +0000)
Fixes #10953

Fixes #10954
The dma-queue-flush.timer will execute the corresponding service
file every hour to call dma and send out all mails. The
dma-cleanup-spool.timer is used to periodly call the service
file for cleaning up the DMA spooler directory.

Both timer files will be enabled during installation of the dma package.

Fixes #10955
This dma-cleanup-spool script cleans up the spool directory from
DMA mail service after defined period of time. Otherwise the spool
dir may be flooded.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
dma/dma-cleanup-spool [new file with mode: 0644]
dma/dma.nm [new file with mode: 0644]
dma/systemd/dma-cleanup-spool.service [new file with mode: 0644]
dma/systemd/dma-cleanup-spool.timer [new file with mode: 0644]
dma/systemd/dma-queue-flush.service [new file with mode: 0644]
dma/systemd/dma-queue-flush.timer [new file with mode: 0644]

diff --git a/dma/dma-cleanup-spool b/dma/dma-cleanup-spool
new file mode 100644 (file)
index 0000000..92af30c
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2015 Michael Tremer <michael.tremer@ipfire.org>               #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+SPOOL_DIR="/var/spool/dma"
+
+find_messages() {
+       find "${SPOOL_DIR}" -type f -name "M*" -mtime +30
+}
+
+remove_message() {
+       local f_message="${1}"
+       local f_queue="${f_message/${SPOOL_DIR}\/M/${SPOOL_DIR}\/Q}"
+
+       # If a message file and a queue file exist, delete both
+       [ -f "${f_message}" ] || return 1
+       [ -f "${f_queue}" ] || return 1
+
+       rm -f "${f_message}" "${f_queue}"
+       return 0
+}
+
+main() {
+       for message in $(find_messages); do
+               remove_message "${message}"
+       done
+
+       return 0
+}
+
+main || exit $?
diff --git a/dma/dma.nm b/dma/dma.nm
new file mode 100644 (file)
index 0000000..259421a
--- /dev/null
@@ -0,0 +1,75 @@
+###############################################################################
+# IPFire.org    - An Open Source Firewall Solution                            #
+# Copyright (C) - IPFire Development Team <info@ipfire.org>                   #
+###############################################################################
+
+name       = dma
+version    = 0.10
+release    = 1
+
+groups     = Mail
+url        = https://github.com/corecode/dma
+license    = BSD
+summary    = DragonFly Mail Agent
+
+description
+       dma is a small Mail Transport Agent (MTA), designed for home and
+       office use. It accepts mails from locally installed Mail User Agents
+       (MUA) and delivers the mails either locally or to a remote destination.
+
+       Remote delivery includes several features like TLS/SSL support and
+       SMTP authentication.
+end
+
+build
+       requires
+               bison
+               flex
+               openssl-devel
+       end
+
+       make_build_targets += PREFIX=%{prefix}
+
+       # Workaround for #10952
+       make_build_targets += LEX="flex -l"
+
+       make_install_targets += PREFIX=%{prefix} \
+               sendmail-link mailq-link install-spool-dirs install-etc
+
+       install_cmds
+               install -m 755 %{DIR_SOURCE}/dma-cleanup-spool %{BUILDROOT}%{sbindir}
+       end
+end
+
+packages
+       package %{name}
+               groups += Base
+
+               script postin
+                       systemctl daemon-reload >/dev/null 2>&1 || :
+                       systemctl --no-reload enable dma-queue-flush.timer >/dev/null 2>&1 || :
+                       systemctl --no-reload enable dma-cleanup-spool.timer >/dev/null 2>&1 || :
+               end
+
+               script preun
+                       systemctl --no-reload disable dma-queue-flush.timer >/dev/null 2>&1 || :
+                       systemctl --no-reload disable dma-cleanup-spool.timer >/dev/null 2>&1 || :
+                       systemctl stop dma-queue-flush.timer >/dev/null 2>&1 || :
+                       systemctl stop dma-cleanup-spool.timer >/dev/null 2>&1 || :
+                       systemctl stop dma-queue-flush.service >/dev/null 2>&1 || :
+                       systemctl stop dma-cleanup-spool.service >/dev/null 2>&1 || :
+               end
+
+               script postun
+                       systemctl daemon-reload >/dev/null 2>&1 || :
+               end
+
+               script postup
+                       systemctl daemon-reload >/dev/null 2>&1 || :
+               end
+       end
+
+       package %{name}-debuginfo
+               template DEBUGINFO
+       end
+end
diff --git a/dma/systemd/dma-cleanup-spool.service b/dma/systemd/dma-cleanup-spool.service
new file mode 100644 (file)
index 0000000..96b5770
--- /dev/null
@@ -0,0 +1,5 @@
+[Unit]
+Description=Cleanup of the DMA mail spool directory
+
+[Service]
+ExecStart=/usr/sbin/dma-cleanup-spool
diff --git a/dma/systemd/dma-cleanup-spool.timer b/dma/systemd/dma-cleanup-spool.timer
new file mode 100644 (file)
index 0000000..57cd716
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Periodly cleanup of the DMA mail spool directory
+
+[Timer]
+OnCalendar=weekly
+Persistent=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dma/systemd/dma-queue-flush.service b/dma/systemd/dma-queue-flush.service
new file mode 100644 (file)
index 0000000..9b48045
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Flushing of the DMA mail queue.
+After=network-online.target
+Requires=network-online.target
+Wants=network-online.target
+
+[Service]
+SendSIGKILL=false
+TimeoutStopSec=0
+ExecStart=/usr/sbin/dma -q
diff --git a/dma/systemd/dma-queue-flush.timer b/dma/systemd/dma-queue-flush.timer
new file mode 100644 (file)
index 0000000..efa1728
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Periodly flushing of the DMA mail queue.
+
+[Timer]
+OnCalendar=hourly
+Persistent=true
+
+[Install]
+WantedBy=multi-user.target