Old ids_register.ksh
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 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
24 #
25 #ident "%Z%%M% %I% %E% SMI"
26 #
27 # DO NOT EDIT THIS FILE
28
29 IDSDIR=/opt/SUNWscids/
30
31 typeset opt
32
33 while getopts 'f:' opt
34 do
35 case "$opt" in
36 f) MYCONFIG=${OPTARG};;
37 *) /usr/bin/echo "ERROR: ${MYNAME} Option ${OPTARG} unknown"
38 /usr/bin/echo "Usage: ${MYNAME} -f <config file>"
39 exit 1;;
40 esac
41 done
42
43 [ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscids/util/ids_config
44
45 . ${MYCONFIG}
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 Validate_command="/opt/SUNWscids/bin/control_ids \
61 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
62 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' validate ids " \
63 -p Port_list=23/tcp -p Stop_signal=9 \
64 -y Resource_dependencies=${HAS_RS},${LH_RS} \
65 ${RS}
66
67 else
68 # Process a failover zone registration
69 #
70 # 1. Validate ${START_TIMEOUT} and ${STOP_TIMEOUT}
71 # 2. Get the failover zone's pfile and determine failover zone name
72 # 3. Build a temporary sczsmf_config file
73 # 4. zlogin to the failover zone execute ids_smf_register
74 # - Creates the SMF manifest using parameter values
75 # - Validate and import the SMF manifest into the SMF repository
76 # 5. Register a SC sczsmf resource to enable/disable the SMF instance
77
78 RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}`
79 rc=$?
80
81 if [ "${rc}" -eq 0 ]
82 then
83 /usr/bin/printf "Sun Cluster resource ${RS} already exists\n"
84 /usr/bin/printf "Cleanup resource before retrying\n"
85 exit 1
86 fi
87
88 if ! [ "${START_TIMEOUT}" -ge 0 ] 2> /dev/null
89 then
90 /usr/bin/printf "START_TIMEOUT value is not an integer\n"
91 exit 1
92 fi
93
94 if ! [ "${STOP_TIMEOUT}" -ge 0 ] 2> /dev/null
95 then
96 /usr/bin/printf "STOP_TIMEOUT value is not an integer\n"
97 exit 1
98 fi
99
100 ZONEPFILE=`/usr/cluster/bin/clrs show -p Start_command ${RS_ZONE} | /usr/bin/grep -w Start_command | \
101 /usr/bin/awk '{ if ($7 == "-P") print $8 }'`
102
103 if [ ! -d "${ZONEPFILE}" ]
104 then
105 /usr/bin/printf "Unable to retrieve zone parameter file directory\n"
106 exit 1
107 else
108 ZONE=`/usr/bin/grep Zonename= ${ZONEPFILE}/sczbt_${RS_ZONE} | /usr/bin/awk -F= '{print $2}' | /usr/xpg4/bin/tr -d '"' `
109 fi
110
111 SERVICE_TAG=svc:/application/sczone-agents:${RS}
112
113 /usr/bin/cat > /var/tmp/${RS}_smf_config <<-EOF
114 RS=${RS}
115 RG=${RG}
116 SCZBT_RS=${RS_ZONE}
117 ZONE=${ZONE}
118 SERVICE=${SERVICE_TAG}
119 RECURSIVE=true
120 STATE=true
121 SERVICE_PROBE="/opt/SUNWscids/bin/control_ids probe ids ${SERVICE_TAG}"
122 EOF
123
124 TMP_WORK_CONFIG=/var/tmp/${RS}_tmp_work_config
125 /usr/bin/cat ${MYCONFIG} | /usr/sbin/zlogin ${ZONE} /usr/bin/cat - \> ${TMP_WORK_CONFIG}
126
127 # Remove an existing FMRI in the zone if it already exists
128 ${IDSDIR}/util/ids_smf_remove -z ${ZONE} -f ${SERVICE_TAG} 2>/dev/null
129
130 # Create and register the ${SERVICE_TAG}
131 if /usr/sbin/zlogin ${ZONE} ${IDSDIR}/util/ids_smf_register ${TMP_WORK_CONFIG}
132 then
133 if /opt/SUNWsczone/sczsmf/util/sczsmf_register -f /var/tmp/${RS}_smf_config
134 then
135 /usr/bin/printf "Registration of ${RS} succeeded\n"
136 else
137 /usr/bin/printf "Registration of ${RS} failed\n"
138 exit 1
139 fi
140 fi
141 fi
142
143 exit 0