New ids_register
1 #!/usr/bin/ksh
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the License).
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/CDDL.txt
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/CDDL.txt.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets [] replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22 #ident "@(#)ids_register 1.1 07/10/19 SMI"
23 #
24 #
25 # DO NOT EDIT THIS FILE
26
27 IDSDIR=/opt/SUNWscids/
28
29 TMP_WORK_CONFIG=/opt/SUNWscids/util/.tmp_work_config
30 typeset opt
31
32 while getopts 'f:' opt
33 do
34 case "$opt" in
35 f) MYCONFIG=${OPTARG};;
36 *) /usr/bin/echo "ERROR: ${MYNAME} Option ${OPTARG} unknown"
37 /usr/bin/echo "Usage: ${MYNAME} -f <config file>"
38 exit 1;;
39 esac
40 done
41
42 [ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscids/util/ids_config
43
44 /usr/bin/cp ${MYCONFIG} ${TMP_WORK_CONFIG}
45 . ${TMP_WORK_CONFIG}
46
47 if [ -z ${RS_ZONE} ]
48 then
49
50 /usr/cluster/bin/clrs create -g ${RG} -t SUNW.gds \
51 -p Start_command="/opt/SUNWscids/bin/control_ids \
52 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
53 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' start ids " \
54 -p Stop_command="/opt/SUNWscids/bin/control_ids \
55 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
56 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' stop ids " \
57 -p Probe_command="/opt/SUNWscids/bin/control_ids \
58 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
59 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' probe ids " \
60 -p Port_list=23/tcp -p Stop_signal=9 \
61 -y Resource_dependencies=${HAS_RS},${LH_RS} \
62 ${RS}
63
64 else
65 ### Process a failover zone registration ###
66 ### All parameter values get stored within the SMF repository ###
67 ### 1. Validate ${START_TIMEOUT} and ${STOP_TIMEOUT} ###
68 ### 2. Get the failover zone's pfile and determine failover zone name ###
69 ### 3. Build a temporary sczsmf_config file (i.e. /tmp/${RS}_smf_config) ###
70 ### 4. zlogin to the failover zone execute mqr_smf_register ###
71 ### - Creates the SMF manifest using parameter values ###
72 ### - Validate and import the SMF manifest into the SMF repository ###
73 ### 5. Register a SC sczsmf resource to enable/disable the SMF instance ###
74
75 RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}`
76 rc=$?
77
78 if [ "${rc}" -eq 0 ]
79 then
80 /usr/bin/printf "Sun Cluster resource ${RS} already exists\n"
81 exit 1
82 fi
83
84 if ! [ "${START_TIMEOUT}" -ge 0 ] 2> /dev/null
85 then
86 /usr/bin/printf "START_TIMEOUT value is not an integer\n"
87 exit 1
88 fi
89
90 if ! [ "${STOP_TIMEOUT}" -ge 0 ] 2> /dev/null
91 then
92 /usr/bin/printf "STOP_TIMEOUT value is not an integer\n"
93 exit 1
94 fi
95
96 ZONEPFILE=`/usr/cluster/bin/clrs show -p Start_command ${RS_ZONE} | /usr/bin/grep -w Start_command | \
97 /usr/bin/awk '{ if ($7 == "-P") print $8 }'`
98
99 if [ ! -d "${ZONEPFILE}" ]
100 then
101 /usr/bin/printf "Unable to retrieve zone parameter file directory\n"
102 exit 1
103 else
104 ZONE=`/usr/bin/grep Zonename= ${ZONEPFILE}/sczbt_${RS_ZONE} | /usr/bin/awk -F= '{print $2}' | /usr/xpg4/bin/tr -d '"' `
105 fi
106
107 SERVICE_TAG=svc:/application/sczone-agents:${RS}
108
109 /usr/bin/cat > /tmp/${RS}_smf_config <<-EOF
110 RS=${RS}
111 RG=${RG}
112 SCZBT_RS=${RS_ZONE}
113 ZONE=${ZONE}
114 SERVICE=${SERVICE_TAG}
115 RECURSIVE=true
116 STATE=true
117 SERVICE_PROBE="/opt/SUNWscids/bin/control_ids probe ids ${SERVICE_TAG}"
118 EOF
119
120 # Remove an existing FMRI in the zone if it already exists
121 ${IDSDIR}/util/ids_smf_remove -z ${ZONE} -f ${SERVICE_TAG} 2>/dev/null
122
123 if /usr/sbin/zlogin ${ZONE} ${IDSDIR}/util/ids_smf_register ${TMP_WORK_CONFIG}
124 then
125 if RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}`
126 then
127 RS_STATE=`/usr/bin/echo ${RS_STATE} | /usr/bin/awk '{print $1}'`
128
129 if [ "${RS_STATE}" = "OFFLINE" ]
130 then
131 /usr/bin/printf "${RS} already registered, but Offline\n"
132 if /usr/cluster/bin/clrs delete ${RS}
133 then
134 /usr/bin/printf "${RS} removed\n"
135 else
136 /usr/bin/printf "Fix or cleanup resources before retrying\n"
137 exit 1
138 fi
139 else
140 /usr/bin/printf "${RS} already registered and is ${RS_STATE}\n"
141 /usr/bin/printf "Registration of ${RS} failed\n"
142 exit 1
143 fi
144 fi
145
146 if /opt/SUNWsczone/sczsmf/util/sczsmf_register -f /tmp/${RS}_smf_config
147 then
148 /usr/bin/printf "Registration of ${RS} succeeded\n"
149 else
150 /usr/bin/printf "Registration of ${RS} failed\n"
151 exit 1
152 fi
153 fi
154
155 /usr/bin/rm ${TMP_WORK_CONFIG}
156 fi
157
158 exit 0