Solaris10 on メールサーバー (Postfix自動起動)


3−1 manifestファイルの作成

DNS同様にスクリプトを作成しようかと思いましたがネットサーフィンしているとSMFへの登録方法を見つけましたのでSMFへ登録してみる事にしました。
manifestに使用するXMLファイルはsendmailのをコピーして編集します。

# cd /var/svc/manifest/network
# cp smtp-sendmail.xml smtp-postfix.xml

smtp-postfix.xmlの編集は基本的にsendmailのPATHやらをpostfixに置き換えるだけです。
」=未変更 「」=変更 「」=削除

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
   Copyright 2004 Sun Microsystems, Inc. All rights reserved.
   Use is subject to license terms.

   ident "@(#)smtp-sendmail.xml 1.11 04/12/16 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 2.5.5'>

<service
   name='network/smtp'
   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>

        :
      { 略 }
        :

   <instance name='sendmail' 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>

        :
      { 略 }
        :

      <!--
      Sendmail is hard-coded to sleep for 60 seconds if it cannot
      determine the FQHN, so the timeout for start must be longer
      than that. For details, see
      http://www.sendmail.org/vendor/sun/differences.html#3.2
      -->
      <exec_method
         type='method'
         name='start'
         exec='/usr/sbin/postfix start'
         timeout_seconds='120' />

      <exec_method
         type='method'
         name='stop'
         exec='/usr/sbin/postfix stop %{restarter/contract}'
      timeout_seconds='60' />

      <exec_method
         type='method'
         name='refresh'
         exec='/usr/sbin/postfixl reload'
         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.sendmail' />
      </property_group>

      <template>
         <common_name>
            <loctext xml:lang='C'>
            Postfix 2.5.5 SMTP mail transfer agent
            </loctext>
         </common_name>
         <documentation>
            <manpage title='postfixl' section='1M'
               manpath='/usr/postfix/man' />
         </documentation>
      </template>

   </instance>

   <stability value='Unstable' />

</service>

</service_bundle>

3−2 manifestファイルのインポート

smtp-postfix.xmlはsvccfgでSMFへインポートします。

# cd /var/svc/manifest/network
# svccfg -vimport ./smtp-postfix.xml

”successful import.”で終了したらSMFへの登録は完了です


3−3 SMFでの起動

svcsでpostfixが停止している事を確認しsvcadmで起動すれば次回からは自動起動します。

# svcs -l postfix
# svcadm enable postfix
# svcs -l postfix

SMFへ登録した事でログもsyslogから分離され”/ver/svc/log/network-smtp:postfix.log”に保存されるようになりました。


[前へ] [目次] [次へ]