Skip to content

SMF support for clamsmtp #69

Description

@mamalos

Hi there!

There's no SMF support for clamsmtp package, so I've written one (by sort-of copy-pasting the relevant pieces from clamd's SMF) and the relevant rc script from FreeBSD.

My SMF file looks like this:

<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='pkgsrc/clamsmtp' type='service' version='0'>
    <create_default_instance enabled='false'/>
    <single_instance/>
    <dependency name='fs' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <dependency name='network-service' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='svc:/network/service'/>
    </dependency>
    <dependency name='clamd' grouping='require_all' restart_on='none' type='service'>
      <service_fmri value='/pkgsrc/clamav:clamd'/>
    </dependency>
    <dependency name='config' grouping='require_all' restart_on='none' type='path'>
      <service_fmri value='file:///opt/local/etc/clamsmtpd.conf'/>
    </dependency>
    <method_context working_directory='/var/clamav'>
      <method_credential group='clamav' user='clamav'/>
    </method_context>
    <exec_method name='start' type='method' exec='/opt/local/lib/svc/method/clamsmtp start' timeout_seconds='0'/>
    <exec_method name='stop' type='method' exec='/opt/local/lib/svc/method/clamsmtp stop' timeout_seconds='0'/>
    <exec_method name='refresh' type='method' exec='/opt/local/lib/svc/method/clamsmtp refresh' timeout_seconds='0'/>
    <property_group name="startd" type="framework">
      <propval name="duration" type="astring" value="contract"/>
      <propval name="ignore_error" type="astring" value="core,signal"/>
    </property_group>
    <stability value='Evolving'/>
    <template>
      <common_name>
        <loctext xml:lang='C'>ClamAV SMTP filter for postfix daemon</loctext>
      </common_name>
    </template>
  </service>
</service_bundle>

And the relevant rc script (/opt/local/lib/svc/method/clamsmtp) looks like this:

#!/sbin/sh
#
# $NetBSD: clamd.sh,v 1.1 2014/03/11 14:34:39 jperkin Exp $
#
# Init script for clamd(8)
#

. /lib/svc/share/smf_include.sh

PIDFILE="/var/clamav/clamsmtp.pid"
CONFIGFILE="/opt/local/etc/clamsmtpd.conf"

case "$1" in
start)
        /opt/local/sbin/clamsmtpd -f ${CONFIGFILE} -p ${PIDFILE}
        ;;
stop)
        kill `/usr/bin/head -1 ${PIDFILE}`
        ;;
refresh)
        # Re-open any log files and reload the database
        kill -HUP `/usr/bin/head -1 ${PIDFILE}`
        ;;
*)
        echo "Usage: $0 {start|stop|refresh}" >&2
        exit 1
        ;;
esac

These are just my 2c. I suppose both files can be refactored to be more complete, but I'm new in Solaris-based OS', so... :)

Activity

  1. self-assigned this
    on Jan 22, 2018
  2. mamash commented on Jan 22, 2018

    @mamash

    Thanks, I implemented something like this and committed to upstream pkgsrc. Note that SMF itself has a built-in process manager, so things like PID files are typically not needed and for simply daemons not even start up scripts are required (i.e. binaries can be called directly).

  3. added a commit that references this issue on Mar 15, 2018
  4. added a commit that references this issue on Mar 31, 2018
  5. added a commit that references this issue on Jul 30, 2018
  6. added a commit that references this issue on Aug 16, 2018
  7. added a commit that references this issue on Oct 31, 2018
  8. added a commit that references this issue on Nov 18, 2018
  9. added a commit that references this issue on Jun 12, 2019
  10. added a commit that references this issue on Jul 22, 2019
  11. added a commit that references this issue on Dec 11, 2019
  12. 129 remaining items

  13. added a commit that references this issue on Jul 13, 2026
  14. added a commit that references this issue on Jul 30, 2026
  15. added a commit that references this issue on Sep 9, 2026
    96399e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions