Print this page
Split Close
Expand all
Collapse all
          --- /workspace/du105637/oscposthot/webrev/usr/src/cmd/ha-services/gds-agents/PostgreSQL/control_pgs.ksh-
          +++ control_pgs.ksh
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14  # When distributing Covered Code, include this CDDL HEADER in each
  15   15  # file and include the License file at usr/src/CDDL.txt.
  16   16  # If applicable, add the following below this CDDL HEADER, with the
  17   17  # fields enclosed by brackets [] replaced with your own identifying
  18   18  # information: Portions Copyright [yyyy] [name of copyright owner]
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  
  23   23  #
  24      -# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
       24 +# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  25   25  # Use is subject to license terms.
  26   26  
  27      -#ident  "%Z%%M% %I%     %E% SMI"
       27 +#ident   "%Z%%M% %I%     %E% SMI"
  28   28  #
  29   29  # Method for the PostrgresSQL agents and the smf manifest
  30   30  #
  31   31  # This method is called by the GDS, manifest, by the optional probe script of the smf method.
  32   32  #
  33   33  # it is started with options and up to 2 parameters:
  34   34  #
  35   35  #
  36      -# $1 start stop or probe
       36 +# $1 start, stop, validate, check_stdby, start_ssh_agent or probe
  37   37  # $2 is the smf service tag name. It is used only if the parameter $1 is probe
  38   38  #
  39   39  
  40   40  MYNAME=`basename ${0}`
  41   41  MYDIR=`dirname ${0}`
  42   42  
  43   43  . ${MYDIR}/../etc/config
  44   44  . ${MYDIR}/../lib/functions_static
  45   45  . ${MYDIR}/functions
  46   46  
↓ open down ↓ 14 lines elided ↑ open up ↑
  61   61  
  62   62  # if no option is set ($OPTIND is 1 in this case), use the smf properties
  63   63  
  64   64  if [ ${OPTIND} -gt 1 ]
  65   65  then
  66   66          shift $((${OPTIND} - 1))
  67   67  else
  68   68  
  69   69          . /lib/svc/share/smf_include.sh
  70   70          
  71      -        # Setting SMF_FMRI in case of validate and probe
       71 +        # Setting SMF_FMRI in case of validate and probe and check_stdby
  72   72          
  73   73          if [ -z "${SMF_FMRI}" ]
  74   74          then
  75   75                  SMF_FMRI=${2}   
  76   76          fi
  77   77  
  78   78          # getting the necessary parameters and filling the variables usually filled
  79   79          # in from options
  80   80  
  81   81          get_fmri_parameters
↓ open down ↓ 10 lines elided ↑ open up ↑
  92   92  
  93   93          # exit from start, if the options are wrong
  94   94  
  95   95          validate_options
  96   96          rc_val=${?}
  97   97          if [ ${rc_val} -ne 0 ]
  98   98          then
  99   99                  terminate ${1} ${rc_val}
 100  100          fi
 101  101          
 102      -        rm ${LOGFILE} 2>/dev/null
      102 +        ${RM} ${LOGFILE} 2>/dev/null
 103  103          
 104  104          # check the content of the options 
 105  105  
 106  106          if validate
 107  107          then
 108  108  
 109  109                  # source the parameter file before the actual start
 110  110  
 111  111                  . ${PARFILE}
 112  112  
↓ open down ↓ 80 lines elided ↑ open up ↑
 193  193  
 194  194          # validate the parameters for application PostrgresSQL
 195  195  
 196  196          validate_options
 197  197          rc_val=${?}
 198  198          if [ ${rc_val} -ne 0 ]
 199  199          then
 200  200                  terminate ${1} ${rc_val}
 201  201          fi
 202  202          
 203      -        rm ${LOGFILE} 2>/dev/null
 204      -        
 205  203          if validate
 206  204          then
 207  205                  rc_val=0
 208  206          else
 209  207                  rc_val=1
 210  208          fi;;
      209 +
      210 +check_stdby)
      211 +
      212 +        # Check if the current host is configured as a PostgreSQL standby host
      213 +
      214 +        validate_options
      215 +        rc_val=${?}
      216 +        if [ ${rc_val} -ne 0 ]
      217 +        then
      218 +                terminate ${1} ${rc_val}
      219 +        fi
 211  220          
      221 +        ${RM} ${LOGFILE} 2>/dev/null
      222 +        
      223 +        # check the content of the options 
      224 +
      225 +        if validate
      226 +        then
      227 +
      228 +                # Source the parameter file, to get the necessary informations for
      229 +                # the check.
      230 +
      231 +                . ${PARFILE}
      232 +
      233 +                if check_stdby
      234 +                then
      235 +                        rc_val=0
      236 +                else
      237 +                        rc_val=1
      238 +                fi
      239 +        else
      240 +                rc_val=1
      241 +        fi;;
      242 +
      243 +start_ssh_agent)
      244 +
      245 +        # start an ssh-agent and decrypt the private ssh-key.
      246 +
      247 +        validate_options
      248 +        rc_val=${?}
      249 +        if [ ${rc_val} -ne 0 ]
      250 +        then
      251 +                terminate ${1} ${rc_val}
      252 +        fi
      253 +        
      254 +        ${RM} ${LOGFILE} 2>/dev/null
      255 +        
      256 +        # check the content of the options 
      257 +
      258 +        if validate
      259 +        then
      260 +
      261 +                # Source the parameter file, to get the informations for the start
      262 +                # of the ssh-agent.
      263 +
      264 +                . ${PARFILE}
      265 +
      266 +                SSH_PASSPHRASE=`${CAT} /tmp/${RESOURCE}-phrase`
      267 +                if start_ssh_agent ${SSH_PASSPHRASE}
      268 +                then
      269 +                        rc_val=0
      270 +                else
      271 +                        rc_val=1
      272 +                fi
      273 +        else
      274 +                rc_val=1
      275 +        fi;;
      276 +        
 212  277  esac
 213  278  
 214  279  # terminate with the right return code, either with an smf specific or the gds/zsh based
 215  280  # return code
 216  281  
 217  282  debug_message "Method: ${MYNAME} ${*} - End terminating"
 218  283  terminate ${1} ${rc_val}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX