Hello SMF List. We're trying to develop an SMF configuration for Hylafax on Solaris 10/SPARC. (We are running the Hylafax build provided from blastwave.org, which does not include an SMF setup - although we've modified slightly the default init script for use with SMF).
The Hylafax startup forks _two_ daemons: faxq and hfaxd. "faxq" dies from time to time - we would like to use SMF to automatically restart this. However, our (naive) configuration does not cater for this situation as SMF won't stop/start the service as a whole unless _both_ "faxq" and "hfaxd" have exited. What is the best way to develop a configuration to cater for this? We would prefer not to have two separate SMF services. (We are happy for "hfaxd" to be restarted in the event that "faxq" has exited or vice versa). Should this be done using (1) dependencies ("hfaxd" could depend on "faxq"), or (2) is there a simple way to tell SMF "if _any_ process dies, restart the whole service"? (Current manifest and method scripts are included below). Alternatively, if anyone out there has already crafted a suitable SMF configuration for Hylafax, we would gratefully accept it! ;-) Thanks in advance. Robert. <?xml version='1.0'?> <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <!-- Description: Service Manifest for Hylafax $Id$ $Source$ WARNING: This file is under RCS control! Do not edit it directly! --> <service_bundle type='manifest' name='export'> <service name='site/hylafax' type='service' version='0'> <create_default_instance enabled='true'/> <single_instance /> <dependency name='fs' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/system/filesystem/local' /> </dependency> <dependency name='net-loopback' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/network/loopback' /> </dependency> <dependency name='net-physical' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/network/physical' /> </dependency> <dependency name='config_data' grouping='require_all' restart_on='none' type='path'> <service_fmri value='file://localhost/opt/csw/var/spool/hylafax/etc/setup.cache' /> </dependency> <dependency name='log_dir' grouping='require_all' restart_on='none' type='path'> <service_fmri value='file://localhost/opt/csw/var/spool/hylafax/log/' /> </dependency> <exec_method name='start' type='method' exec='/local/svc/method/cswhylafax start' timeout_seconds='60'> <method_context /> </exec_method> <exec_method name='stop' type='method' exec='/local/svc/method/cswhylafax stop' timeout_seconds='60'> <method_context /> </exec_method> <property_group name='startd' type='framework'> <propval name='ignore_error' type='astring' value='core,signal'/> </property_group> <stability value='Unstable'/> <template> <common_name> <loctext xml:lang='C'>Hylafax</loctext> </common_name> </template> </service> </service_bundle> #! /bin/sh # $Id: hylafax.in,v 1.9 2001/06/05 03:01:43 tim Exp $ # # chkconfig: 2345 97 05 # # description: HylaFAX(tm) is a sophisticated enterprise-strength fax # package for class 1 and 2 fax modems on unix systems. # This init script is the preferred way to start HylaFAX, # but does not, by default, activate any modems. Consult # the faxgetty(8) and faxmodem(8) man pages for more info. # # Warning, this file was automatically created by the HylaFAX configure script # # HylaFAX Facsimile Software # # Copyright (c) 1990-1996 Sam Leffler # Copyright (c) 1991-1996 Silicon Graphics, Inc. # HylaFAX is a trademark of Silicon Graphics # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. # # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. # # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # # VERSION: 4.2.1 # DATE: Mon Jun 13 08:35:36 EDT 2005 # TARGET: sparc-sun-solaris2.8 # . /lib/svc/share/smf_include.sh # # fax server control # # NB: This script assumes faxgetty processes are managed by init # SPOOL=/opt/csw/var/spool/hylafax test -f $SPOOL/etc/setup.cache || { cat<<EOF FATAL ERROR: $SPOOL/etc/setup.cache is missing! The file $SPOOL/etc/setup.cache is not present. This probably means the machine has not been setup using the faxsetup(1) command. Read the documentation on setting up HylaFAX before you startup a server system. EOF exit 1 } . $SPOOL/etc/setup.cache # Just in case these are not in setup.cache yet if [ -z "$HFAXD_SERVER" ]; then HFAXD_SERVER=yes fi if [ -z "$FAXQ_SERVER" ]; then FAXQ_SERVER=yes fi if [ -z "$HFAXD_OLD_PROTOCOL" ]; then HFAXD_OLD_PROTOCOL=no fi if [ -z "$HFAXD_SNPP_SERVER" ]; then HFAXD_SNPP_SERVER=no fi IS_ON=/etc/chkconfig # NB: chkconfig is IRIX- and Linux-specific FAXQ=$SBIN/faxq HFAXD=$LIBEXEC/hfaxd FAXQUIT=$SBIN/faxquit FAXPORT=hylafax # designated port for new protocol SNPPPORT=444 # official port for SNPP if test ! -x $IS_ON ; then IS_ON=true fi if $IS_ON verbose ; then ECHO=echo else # For a quiet startup and shutdown ECHO=: fi # # Figure out which brand of echo we have and define prompt # and printf shell functions accordingly. Note that we # assume that if the System V-style echo is not present, # then the BSD printf program is available. These functions # are defined here so that they can be tailored on a per-site, # etc. basis. # if [ `echo foo\\\c`@ = "foo@" ]; then # System V-style echo supports \r # and \c which is all that we need printf() { $ECHO "$*\\c" } elif [ "`echo -n foo`@" = "foo@" ]; then # BSD-style echo; use echo -n to get # a line without the trailing newline printf() { $ECHO -n "$*" } else # something else; do without printf() { $ECHO "$*" } fi # # # killall -SIGNAL process-name # # Emulate the necessary functionality of the # killall program # killall() { # NB: ps ax should give an error on System V, so we try it first! pid="`ps ax 2>/dev/null | $AWK \"\ /[\/ (]$2[ )]/ {print \\$1;} /[\/ ]$2\$/ {print \\$1;}\"`" test "$pid" || pid="`ps -e 2>/dev/null | $AWK \"/ $2[ ]*\$/ {print \\$1;}\"`" test "$pid" && kill $1 $pid; return } case $1 in 'start') if $IS_ON fax && test -x $FAXQ; then if test $FAXQ_SERVER = yes ; then pkill -15 faxq fi if test $HFAXD_SERVER = yes ; then pkill -15 hfaxd fi printf "HylaFAX:" if test $FAXQ_SERVER = yes ; then $FAXQ; printf " faxq" fi if test $HFAXD_SERVER = yes ; then HFAXD="$HFAXD -i $FAXPORT" HFAXMSG=" hfaxd" if [ $HFAXD_OLD_PROTOCOL = yes ]; then HFAXD="$HFAXD -o 4557" HFAXMSG="$HFAXMSG (with old protocol" else HFAXMSG="$HFAXMSG (without old protocol" fi if [ $HFAXD_SNPP_SERVER = yes ]; then HFAXD="$HFAXD -s $SNPPPORT" HFAXMSG="$HFAXMSG & with SNPP support)" else HFAXMSG="$HFAXMSG & without SNPP support)" fi $HFAXD ; printf "$HFAXMSG" fi if test $FAXQ_SERVER != yes -a $HFAXD_SERVER != yes ; then printf " not started (script disabled by configure)" fi $ECHO "." fi ;; 'stop') $ECHO "Stopping HylaFAX Servers." $FAXQUIT >/dev/null 2>&1 pkill -15 hfaxd sleep 3 pgrep -v hfaxd > /dev/null ;; 'start_msg') $ECHO "Starting HylaFAX Servers." ;; 'stop_msg') $ECHO "Stopping HylaFAX Servers." ;; *) $ECHO "usage: hylafax {start|stop|start_msg|stop_msg}" ;; esac