Udiff control_pgs.ksh
--- /workspace/du105637/oscposthot/webrev/usr/src/cmd/ha-services/gds-agents/PostgreSQL/control_pgs.ksh-        Tue Apr 22 05:14:54 2008
+++ control_pgs.ksh     Mon Apr 21 06:08:35 2008
@@ -19,11 +19,11 @@
 #
 # CDDL HEADER END
 #
 
 #
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 
 #ident "%Z%%M% %I%     %E% SMI"
 #
 # Method for the PostrgresSQL agents and the smf manifest
@@ -31,11 +31,11 @@
 # This method is called by the GDS, manifest, by the optional probe script of the smf method.
 #
 # it is started with options and up to 2 parameters:
 #
 #
-# $1 start stop or probe
+# $1 start, stop, validate, check_stdby, start_ssh_agent or probe
 # $2 is the smf service tag name. It is used only if the parameter $1 is probe
 #
 
 MYNAME=`basename ${0}`
 MYDIR=`dirname ${0}`
@@ -66,11 +66,11 @@
        shift $((${OPTIND} - 1))
 else
 
        . /lib/svc/share/smf_include.sh
        
-       # Setting SMF_FMRI in case of validate and probe
+       # Setting SMF_FMRI in case of validate and probe and check_stdby
         
        if [ -z "${SMF_FMRI}" ]
        then
                SMF_FMRI=${2}   
        fi
@@ -97,11 +97,11 @@
        if [ ${rc_val} -ne 0 ]
        then
                terminate ${1} ${rc_val}
        fi
        
-       rm ${LOGFILE} 2>/dev/null
+       ${RM} ${LOGFILE} 2>/dev/null
        
        # check the content of the options 
 
        if validate
        then
@@ -198,17 +198,82 @@
        if [ ${rc_val} -ne 0 ]
        then
                terminate ${1} ${rc_val}
        fi
        
-       rm ${LOGFILE} 2>/dev/null
+       if validate
+       then
+               rc_val=0
+       else
+               rc_val=1
+       fi;;
        
+check_stdby)
+
+       # Check if the current host is configured as a PostgreSQL standby host
+
+       validate_options
+       rc_val=${?}
+       if [ ${rc_val} -ne 0 ]
+       then
+               terminate ${1} ${rc_val}
+       fi
+       
+       ${RM} ${LOGFILE} 2>/dev/null
+       
+       # check the content of the options 
+
        if validate
        then
+
+               # Source the parameter file, to get the necessary informations for
+               # the check.
+
+               . ${PARFILE}
+
+               if check_stdby
+               then
                rc_val=0
        else
                rc_val=1
+               fi
+       else
+               rc_val=1
+       fi;;
+
+start_ssh_agent)
+
+       # start an ssh-agent and decrypt the private ssh-key.
+
+       validate_options
+       rc_val=${?}
+       if [ ${rc_val} -ne 0 ]
+       then
+               terminate ${1} ${rc_val}
+       fi
+       
+       ${RM} ${LOGFILE} 2>/dev/null
+       
+       # check the content of the options 
+
+       if validate
+       then
+
+               # Source the parameter file, to get the informations for the start
+               # of the ssh-agent.
+
+               . ${PARFILE}
+
+               SSH_PASSPHRASE=`${CAT} /tmp/${RESOURCE}-phrase`
+               if start_ssh_agent ${SSH_PASSPHRASE}
+               then
+                       rc_val=0
+               else
+                       rc_val=1
+               fi
+       else
+               rc_val=1
        fi;;
        
 esac
 
 # terminate with the right return code, either with an smf specific or the gds/zsh based