NOTE: You should disable your init scripts in /etc/rc2.d /etc/rc3.d
First we must create a:
/var/svc/manifest/site/postfix.xml
file that contains the following:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
Copyright 2005 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
CDDL HEADER START
The contents of this file are subject to the terms of the
Common Development and Distribution License, Version 1.0 only
(the "License"). You may not use this file except in compliance
with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
ident "@(#)smtp-postfix.xml 1.12 05/06/08 SMI"
NOTE: This service manifest is not editable; its contents will
be overwritten by package or patch operations, including
operating system upgrade. Make customizations in a different
file.
-->
<service_bundle type='manifest' name='postfix:default'>
<service
name='site/postfix'
type='service'
version='1'>
<single_instance />
<dependency
name='fs-local'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/system/filesystem/local' />
</dependency>
<dependency
name='pgsql'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/site/pgsql' />
</dependency>
<dependency
name='clamav'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/site/clamav' />
</dependency>
<!--
Only uncomment if you're using the dspam SMF service in daemon mode -wpool
--->
<dependency
name='dspam'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/site/dspam' />
</dependency>
<dependency
name='network-service'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/network/service' />
</dependency>
<dependency
name='name-services'
grouping='require_all'
restart_on='refresh'
type='service'>
<service_fmri value='svc:/milestone/name-services' />
</dependency>
<dependency
name='identity'
grouping='optional_all'
restart_on='refresh'
type='service'>
<service_fmri value='svc:/system/identity:domain' />
</dependency>
<dependency
name='system-log'
grouping='optional_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/system/system-log' />
</dependency>
<instance name='postfix' enabled='false'>
<dependency
name='config-file'
grouping='require_all'
restart_on='refresh'
type='path'>
<service_fmri
value='file://localhost/etc/postfix/main.cf' />
</dependency>
<dependency
name='nsswitch'
grouping='require_all'
restart_on='refresh'
type='path'>
<service_fmri
value='file://localhost/etc/nsswitch.conf' />
</dependency>
<!--
If autofs is enabled, wait for it to get users' home
directories.
-->
<dependency
name='autofs'
grouping='optional_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/system/filesystem/autofs' />
</dependency>
<dependent
name='smtp-postfix_multi-user'
grouping='optional_all'
restart_on='none'>
<service_fmri
value='svc:/milestone/multi-user' />
</dependent>
<exec_method
type='method'
name='start'
exec='/lib/svc/method/svc-postfix start'
timeout_seconds='120' />
<exec_method
type='method'
name='stop'
exec='/lib/svc/method/svc-postfix stop %{restarter/contract}'
timeout_seconds='60' />
<exec_method
type='method'
name='refresh'
exec='/lib/svc/method/svc-postfix refresh'
timeout_seconds='60' />
<property_group name='startd' type='framework'>
<propval name='ignore_error' type='astring'
value='core,signal' />
</property_group>
<property_group name='general' type='framework'>
<propval name='action_authorization' type='astring'
value='solaris.smf.manage.postfix' />
</property_group>
<template>
<common_name>
<loctext xml:lang='C'>
postfix SMTP mail transfer agent
</loctext>
</common_name>
<documentation>
<manpage title='postfix' section='1M'
manpath='/usr/man' />
</documentation>
Now, we need to create a method file:
/lib/svc/method/svc-postfix
which contains:
{
#!/bin/sh -e
# Start or stop Postfix
#
# 05/06
# William Pool
# rotaecho@yahoo.com
. /lib/svc/share/smf_include.sh
PATH=/usr/bin:/sbin:/usr/sbin:/usr/lib/postfix
DAEMON=/usr/sbin/postfix
PIDFILE=/var/run/postfix.pid
NAME=Postfix
test -x $DAEMON -a -f /etc/postfix/main.cf || exit 0
case "$1" in
start)
echo "Starting mail transport agent: Postfix\c"
${DAEMON} start 2>&1 |
(grep -v 'starting the Postfix' 1>&2 || /bin/true)
echo "."
;;
stop)
echo "Stopping mail transport agent: Postfix\c"
${DAEMON} stop 2>&1 |
(grep -v 'stopping the Postfix' 1>&2 || /bin/true)
echo "."
;;
restart)
$0 stop
$0 start
;;
force-reload|reload)
echo "Reloading Postfix configuration...\c"
${DAEMON} reload 2>&1 |
(grep -v 'refreshing the Postfix' 1>&2 || /bin/true)
echo "done."
;;
flush)
${DAEMON} flush
;;
check)
${DAEMON} check
;;
*)
echo "Usage: /etc/init.d/postfix {start|stop|restart|reload|flush|check|force-reload}"
exit 1
;;
esac
exit0
Change permissions of the files:
chmod 555 /lib/svc/method/svc-postfix chown root:bin /lib/svc/method/svc-postfix chmod 444 /var/svc/manifest/site/postfix.xml chown root:sys /var/svc/manifest/site/postfix.xml
Install the Postfix SMF
/usr/sbin/svccfg import /var/svc/manifest/site/postfix.xml /usr/sbin/svcadm -v enable|disable|restart postfix
