Solaris 10 popfile SMF service bundle

Posted on February 13, 2005

popfile.sh

#!/sbin/sh

. /lib/svc/share/smf_include.sh

POPFILE_ROOT=/opt/popfile
POPFILE_USER=$POPFILE_ROOT
POPFILE=$POPFILE_ROOT/popfile.pl
POPFILE_PID="/var/run/popfile.pid"
PID=`cat ${POPFILE_PID} 2> /dev/null`

CONF_FILE=$POPFILE_ROOT/popfile.cfg
LOGDIR=/var/log/popfile

[ ! -f ${CONF_FILE} ] && exit $SMF_EXIT_ERR_CONFIG

case "$1" in
start)
        if [ "${PID}" = "" ] ; then
            cd ${POPFILE_ROOT}
            ${POPFILE}set config_piddir=/var/run/ –set logger_logdir=$LOGDIR &> $LOGDIR/popfile &
            echo "Starting POPFile as background process:  done"
        else
            echo "Starting POPFile as background process:  POPFile already running"
        fi
        ;;
’stop’)
        if [ "${PID}" = "" ] ; then
            echo "Stopping POPFile: POPFile not running"
        else
            kill $PID
            if [ -e $POPFILE_PID ] ; then
               rm ${POPFILE_PID}
            fi
            PID=""
            echo "Stopping POPFile:  done"
        fi
                exit $SMF_EXIT_OK
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac

————————————————————-
popfile.xml

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!– thanks http://blogs.sun.com/roller/page/tdw/20050204#my_first_foray_into_service>
<service_bundle type="manifest" name="LOCAL:POPFILE">
  <service name="site/popfile" type="service" version="1">
<!– Only want one instance and I want it enabled by default –>
    <create_default_instance enabled="true"/>
    <single_instance/>
<!– Can’t do anything without a network layer –>
    <dependency name="loopback" grouping="require_all" restart_on="error" type="service">
      <service_fmri value="svc:/network/loopback:default"/>
    </dependency>
    <dependency name="physical" grouping="require_all" restart_on="error" type="service">
      <service_fmri value="svc:/network/physical:default"/>
    </dependency>
<!– popfile needs to be able to resolve host names. –>
    <dependency name="name-services" grouping="require_all" restart_on="refresh" type="service">
      <service_fmri value="svc:/milestone/name-services"/>
    </dependency>
<!– Need to ensure that /opt is mounted –>
    <dependency name="fs-local" grouping="require_all" restart_on="none" type="service">
      <service_fmri value="svc:/system/filesystem/local"/>
    </dependency>
    <exec_method type="method" name="start" exec="/opt/popfile/popfile.sh start" timeout_seconds="60"/>
    <exec_method type="method" name="stop" exec="/opt/popfile/popfile.sh stop" timeout_seconds="5"/>
    <stability value="Unstable"/>
    <template>
      <common_name>
        <loctext xml:lang="C">POPFile is an automatic mail classification tool</loctext>
      </common_name>
      <documentation>
        <doc_link name="getpopfile.org" uri="http://popfile.sourceforge.net/"/>
      </documentation>
    </template>
  </service>
</service_bundle>

———————————-
svccfg validate popfile.xml
svccfg import popfile.xml

Filed Under Uncategorized |

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name

Email

Website

Comments

For spam detection purposes, please copy the number 6166 to the field below:

© Copyright 0xDEADBEEFCAFE • Powered by Wordpress • Design by Sebastin.

free web hit counter