Print this page
Split Close
Expand all
Collapse all
          --- /workspace/du105637/oscposthot/webrev/usr/src/cmd/ha-services/gds-agents/PostgreSQL/pgs_register.ksh-
          +++ pgs_register.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   27  
  28   28  #ident  "%Z%%M% %I%     %E% SMI"
  29   29  
  30   30  #
  31   31  #  This script takes 1 options.
  32   32  #  -f filename states a config file different from pgs_config.
  33   33  #     This file will be sourced instead of pgs_config if -f filename is specified
  34   34  #
  35   35  
  36   36  
  37   37  # Set generic variables:
  38   38  
  39   39  BINDIR=/opt/SUNWscPostgreSQL/bin
  40   40  UTILDIR=/opt/SUNWscPostgreSQL/util
  41   41  SMFUTILDIR=/opt/SUNWsczone/sczsmf/util
  42   42  DIRNAME=/usr/bin/dirname
  43      -ECHO=/usr/bin/${ECHO}
       43 +ECHO=/usr/bin/echo
       44 +STTY=/usr/bin/stty
  44   45  
  45   46  MYNAME=`basename ${0}`
  46   47  MYDIR=`dirname ${0}`
  47   48  
  48   49  . ${MYDIR}/../etc/config
  49   50  . ${MYDIR}/../lib/functions_static
  50   51  . ${MYDIR}/../bin/functions
  51   52  
  52   53  
  53   54  global_zone()
↓ open down ↓ 7 lines elided ↑ open up ↑
  61   62                return 1
  62   63          fi 
  63   64  
  64   65          # define your start, stop, probe an validate command
  65   66  
  66   67          start_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} start"
  67   68          stop_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} stop"
  68   69          probe_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} probe"
  69   70          validate_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} validate"
  70   71  
       72 +        # determine whether the resource runs in the global zone or in a zone node
       73 +        # and set the zcommand to the appropriate zlogin comand
       74 +
       75 +        zcommand=
       76 +        rgs_zone=$(rgs_zonename)
       77 +        if [ -n "${rgs_zone}" ]
       78 +        then
       79 +                zcommand="${ZLOGIN} ${rgs_zone} " 
       80 +        fi
       81 +        
       82 +        # create the <resorce name>-phrase if required
       83 +
       84 +        if [ -n "${SSH_PASSDIR}" ] 
       85 +        then
       86 +                if ! store_passphrase
       87 +                then
       88 +                        return 1
       89 +                fi
       90 +        fi
       91 +
  71   92          # register your resource
  72   93  
  73   94          if /usr/cluster/bin/scrgadm -pvv -t SUNW.gds | /usr/bin/grep Validate_command>/dev/null 2>&1
  74   95          then
  75   96  
  76   97                  # register in 3.2 style
  77   98  
  78   99                  if [ -n "${LH}" ]
  79  100                  then
  80  101                          /usr/cluster/bin/scrgadm -a -j ${RS} -g ${RG} -t SUNW.gds \
↓ open down ↓ 56 lines elided ↑ open up ↑
 137  158          fi
 138  159          
 139  160          # validate the resource only, if the validation is not present
 140  161  
 141  162          if ! /usr/cluster/bin/scrgadm -pvv -t SUNW.gds | /usr/bin/grep Validate_command>/dev/null 2>&1
 142  163          then
 143  164  
 144  165                  # VALIDATE RESOURCE
 145  166                  
 146  167                  ${ECHO} "Validate resource ${RS} in resourcegroup ${RG}"
 147      -        
 148      -                # determine whether the resource runs in the global zone or in a prepared zone
 149      -                # and set the zcommand to the appropriate zlogin comand
 150      -        
 151      -                zcommand=
 152      -                rgs_zone=$(rgs_zonename)
 153      -                if [ -n "${rgs_zone}" ]
 154      -                then
 155      -                        zcommand="/usr/sbin/zlogin ${rgs_zone} " 
 156      -                fi
 157  168                  
 158  169                  # validate the contents of the parameter file
 159  170          
 160  171                  ${zcommand} ${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} validate
 161  172                  
 162  173                  St=$?
 163  174                  
 164  175                  if [ "${St}" -ne 0 ]; then
 165  176                          ${ECHO} "Validation of resource ${RS} failed, please correct the wrong parameters."
 166  177                          ${ECHO} "Removing resource ${RS} from the cluster configuration."
↓ open down ↓ 17 lines elided ↑ open up ↑
 184  195  
 185  196          SERVICE_TAG=svc:/application/sczone-agents:${RS}
 186  197  
 187  198          if [ ! -f ${SMFUTILDIR}/sczsmf_config ]
 188  199          then
 189  200                  ${ECHO}  ${SMFUTILDIR}/sczsmf_config does not exist. Make sure, that \
 190  201                        Sun Cluster HA for Solaris container is intalled in the global zone
 191  202                  return 1
 192  203          fi
 193  204  
      205 +        
      206 +        # create the <resorce name>-phrase if required
      207 +
      208 +        zcommand="${ZLOGIN} ${ZONE} " 
      209 +        
      210 +        # create the <resorce name>-phrase if required
      211 +
      212 +        if [ -n "${SSH_PASSDIR}" ] 
      213 +        then
      214 +                if  store_passphrase
      215 +                then
      216 +                        ${zcommand} ${CHOWN} ${USER} ${SSH_PASSDIR}/${RS}-phrase
      217 +                else
      218 +                        return 1
      219 +                fi
      220 +        fi
      221 +                
      222 +
 194  223  # prepare the config file
 195  224  
 196  225          cp ${SMFUTILDIR}/sczsmf_config ${SMFUTILDIR}/sczsmf_config.work
 197  226          cat << EOF > ${SMFUTILDIR}/sczsmf_config 
 198  227  
 199  228  #
 200  229  # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 201  230  # Use is subject to license terms.
 202  231  #
 203  232  # This file will be sourced in by sczsmf_register and the parameters
↓ open down ↓ 89 lines elided ↑ open up ↑
 293  322                  ${ECHO} "The registration of the manifest did not complete, fix the errors and retry"
 294  323                  ret_code=0
 295  324          fi
 296  325  
 297  326          /usr/sbin/zlogin ${ZONE} /usr/bin/rm /tmp/pgs_config.work
 298  327          
 299  328          return ${ret_code}
 300  329  
 301  330  }
 302  331  
      332 +store_passphrase()
      333 +{
      334 +        
      335 +        # create the <resorce name>-phrase 
 303  336  
      337 +        ${zcommand} ${TEST} ${SSH_PASSDIR}      
      338 +        if [ ${?} -ne 0 ]
      339 +        then
      340 +                ${ECHO} "The directory ${SSH_PASSDIR} which is necessary to store the passphrase file does not exist"
      341 +                return 1
      342 +                
      343 +        fi
      344 +        ${zcommand} ${RM} ${SSH_PASSDIR}/${RS}-phrase 2>/dev/null
      345 +        ${zcommand} ${TOUCH} ${SSH_PASSDIR}/${RS}-phrase
      346 +        ${zcommand} ${CHMOD} 600 ${SSH_PASSDIR}/${RS}-phrase
      347 +        if [ -n "${zcommand}" ]
      348 +        then
      349 +                ${zcommand} ${ECHO} ${passphrase} \>\>${SSH_PASSDIR}/${RS}-phrase
      350 +        else
      351 +                ${ECHO} ${passphrase} >>${SSH_PASSDIR}/${RS}-phrase
      352 +        fi
      353 +        ${zcommand} ${CHMOD} 400 ${SSH_PASSDIR}/${RS}-phrase
      354 +        return 0
      355 +                
      356 +}
      357 +
 304  358  MYCONFIG=
 305  359  ZONETYPE=global
 306  360  
 307  361  typeset opt
 308  362  
 309  363  while getopts 'f:' opt
 310  364  do
 311  365          case "${opt}" in
 312  366                  f)      MYCONFIG=${OPTARG};;
 313  367                  *)      ${ECHO} "ERROR: ${MYNAME} Option ${OPTARG} unknown - early End. Only -f is valid"
↓ open down ↓ 8 lines elided ↑ open up ↑
 322  376  then
 323  377          ${ECHO} "sourcing ${MYCONFIG} and create a working copy under ${UTILDIR}/pgs_config.work"
 324  378          cp ${MYCONFIG} ${UTILDIR}/pgs_config.work
 325  379          . ${MYCONFIG}
 326  380  else
 327  381          PKGCONF=`dirname $0`/pgs_config
 328  382          ${ECHO} "sourcing ${PKGCONF}"
 329  383          . ${PKGCONF}
 330  384  fi
 331  385  
      386 +# getting the passphrase if required
      387 +
      388 +if [ -n "${SSH_PASSDIR}" ]
      389 +then
      390 +
      391 +        ${ECHO} "Enter the passphrase of your PostgreSQL user."  
      392 +        ${STTY} -echo
      393 +        read passphrase
      394 +        ${STTY} echo
      395 +        if [ -z "${passphrase}" ]
      396 +        then
      397 +                ${ECHO} "The passphrase is missing, rerun the pgs_register script"
      398 +                exit 1
      399 +        fi
      400 +        ${ECHO} "Verify your passphrase"
      401 +        ${STTY} -echo
      402 +        read passphrase2
      403 +        ${STTY} echo
      404 +        if [ "${passphrase}" != "${passphrase2}" ]
      405 +        then
      406 +                ${ECHO} "The passphrase verification does not match, rerun the pgs_register script"
      407 +                exit 1
      408 +        fi
      409 +        
      410 +fi
      411 +
 332  412  # Registering the resource
 333  413  
 334  414  if [ -n "${ZONE}" ]
 335  415  then
 336  416          local_zone_smf
 337  417  else
 338  418          global_zone
 339  419  fi
 340  420  
 341  421  if [ -f ${UTILDIR}/pgs_config.work ]
 342  422  then
 343  423          ${ECHO} " remove the working copy ${UTILDIR}/pgs_config.work"
 344  424          rm ${UTILDIR}/pgs_config.work
 345  425  fi
 346  426  
 347  427  exit 0
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX