diff --git a/usr.sbin/sendmail/Makefile b/usr.sbin/sendmail/Makefile --- a/usr.sbin/sendmail/Makefile +++ b/usr.sbin/sendmail/Makefile @@ -25,6 +25,13 @@ BINMODE=2555 .endif +# Add a pkg(8) trigger that automatically restarts sendmail on upgrade. +# This is required because if /var/spool/mqueue is deleted and recreated, +# sendmail will stop working until it's restarted. +FILESGROUPS= TRIGGERS +TRIGGERS= sendmail.ucl +TRIGGERSDIR= /usr/share/pkg/triggers + # Define the database format to use for aliases et al. DBMDEF= -DNEWDB # If you don't want NIS alias/map support, comment out this line diff --git a/usr.sbin/sendmail/sendmail.ucl b/usr.sbin/sendmail/sendmail.ucl new file mode 100644 --- /dev/null +++ b/usr.sbin/sendmail/sendmail.ucl @@ -0,0 +1,34 @@ +/* + * SPDX-License-Identifier: ISC + * + * Copyright (c) 2025 Lexi Winter + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +path: [ + "/var/spool/mqueue", + "/var/spool/clientmqueue", +] + +trigger: { + type: lua + sandbox: false + script: </dev/null 2>&1 && " .. + "echo 'Restarting sendmail(8).' && " .. + "/usr/sbin/service sendmail restart"}) +EOD +} +