Udiff pgs_register.ksh
--- /workspace/du105637/oscposthot/webrev/usr/src/cmd/ha-services/gds-agents/PostgreSQL/pgs_register.ksh- Tue Apr 22 05:14:55 2008
+++ pgs_register.ksh Tue Apr 22 04:57:04 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"
@@ -38,11 +38,12 @@
BINDIR=/opt/SUNWscPostgreSQL/bin
UTILDIR=/opt/SUNWscPostgreSQL/util
SMFUTILDIR=/opt/SUNWsczone/sczsmf/util
DIRNAME=/usr/bin/dirname
-ECHO=/usr/bin/${ECHO}
+ECHO=/usr/bin/echo
+STTY=/usr/bin/stty
MYNAME=`basename ${0}`
MYDIR=`dirname ${0}`
. ${MYDIR}/../etc/config
@@ -66,10 +67,30 @@
start_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} start"
stop_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} stop"
probe_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} probe"
validate_command="${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} validate"
+ # determine whether the resource runs in the global zone or in a zone node
+ # and set the zcommand to the appropriate zlogin comand
+
+ zcommand=
+ rgs_zone=$(rgs_zonename)
+ if [ -n "${rgs_zone}" ]
+ then
+ zcommand="${ZLOGIN} ${rgs_zone} "
+ fi
+
+ # create the <resorce name>-phrase if required
+
+ if [ -n "${SSH_PASSDIR}" ]
+ then
+ if ! store_passphrase
+ then
+ return 1
+ fi
+ fi
+
# register your resource
if /usr/cluster/bin/scrgadm -pvv -t SUNW.gds | /usr/bin/grep Validate_command>/dev/null 2>&1
then
@@ -143,20 +164,10 @@
# VALIDATE RESOURCE
${ECHO} "Validate resource ${RS} in resourcegroup ${RG}"
- # determine whether the resource runs in the global zone or in a prepared zone
- # and set the zcommand to the appropriate zlogin comand
-
- zcommand=
- rgs_zone=$(rgs_zonename)
- if [ -n "${rgs_zone}" ]
- then
- zcommand="/usr/sbin/zlogin ${rgs_zone} "
- fi
-
# validate the contents of the parameter file
${zcommand} ${BINDIR}/control_pgs -R ${RS} -G ${RG} -P ${PFILE} validate
St=$?
@@ -189,10 +200,28 @@
${ECHO} ${SMFUTILDIR}/sczsmf_config does not exist. Make sure, that \
Sun Cluster HA for Solaris container is intalled in the global zone
return 1
fi
+
+ # create the <resorce name>-phrase if required
+
+ zcommand="${ZLOGIN} ${ZONE} "
+
+ # create the <resorce name>-phrase if required
+
+ if [ -n "${SSH_PASSDIR}" ]
+ then
+ if store_passphrase
+ then
+ ${zcommand} ${CHOWN} ${USER} ${SSH_PASSDIR}/${RS}-phrase
+ else
+ return 1
+ fi
+ fi
+
+
# prepare the config file
cp ${SMFUTILDIR}/sczsmf_config ${SMFUTILDIR}/sczsmf_config.work
cat << EOF > ${SMFUTILDIR}/sczsmf_config
@@ -298,11 +327,36 @@
return ${ret_code}
}
+store_passphrase()
+{
+ # create the <resorce name>-phrase
+
+ ${zcommand} ${TEST} ${SSH_PASSDIR}
+ if [ ${?} -ne 0 ]
+ then
+ ${ECHO} "The directory ${SSH_PASSDIR} which is necessary to store the passphrase file does not exist"
+ return 1
+
+ fi
+ ${zcommand} ${RM} ${SSH_PASSDIR}/${RS}-phrase 2>/dev/null
+ ${zcommand} ${TOUCH} ${SSH_PASSDIR}/${RS}-phrase
+ ${zcommand} ${CHMOD} 600 ${SSH_PASSDIR}/${RS}-phrase
+ if [ -n "${zcommand}" ]
+ then
+ ${zcommand} ${ECHO} ${passphrase} \>\>${SSH_PASSDIR}/${RS}-phrase
+ else
+ ${ECHO} ${passphrase} >>${SSH_PASSDIR}/${RS}-phrase
+ fi
+ ${zcommand} ${CHMOD} 400 ${SSH_PASSDIR}/${RS}-phrase
+ return 0
+
+}
+
MYCONFIG=
ZONETYPE=global
typeset opt
@@ -327,10 +381,36 @@
PKGCONF=`dirname $0`/pgs_config
${ECHO} "sourcing ${PKGCONF}"
. ${PKGCONF}
fi
+# getting the passphrase if required
+
+if [ -n "${SSH_PASSDIR}" ]
+then
+
+ ${ECHO} "Enter the passphrase of your PostgreSQL user."
+ ${STTY} -echo
+ read passphrase
+ ${STTY} echo
+ if [ -z "${passphrase}" ]
+ then
+ ${ECHO} "The passphrase is missing, rerun the pgs_register script"
+ exit 1
+ fi
+ ${ECHO} "Verify your passphrase"
+ ${STTY} -echo
+ read passphrase2
+ ${STTY} echo
+ if [ "${passphrase}" != "${passphrase2}" ]
+ then
+ ${ECHO} "The passphrase verification does not match, rerun the pgs_register script"
+ exit 1
+ fi
+
+fi
+
# Registering the resource
if [ -n "${ZONE}" ]
then
local_zone_smf