5
# Sun Grid Engine service tag management script
8
##########################################################################
10
# The Contents of this file are made available subject to the terms of
11
# the Sun Industry Standards Source License Version 1.2
13
# Sun Microsystems Inc., March, 2001
16
# Sun Industry Standards Source License Version 1.2
17
# =================================================
18
# The contents of this file are subject to the Sun Industry Standards
19
# Source License Version 1.2 (the "License"); You may not use this file
20
# except in compliance with the License. You may obtain a copy of the
21
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
23
# Software provided under this License is provided on an "AS IS" basis,
24
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
25
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
26
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
27
# See the License for the specific provisions governing your rights and
28
# obligations concerning the Software.
30
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
32
# Copyright: 2001 by Sun Microsystems, Inc.
34
# All Rights Reserved.
36
##########################################################################
40
#---------------------------------------------------------------------------
41
# This script requires the that $SGE_ROOT and $SGE_CELL be set
44
if [ -z "$SGE_ROOT" -o -z "$SGE_CELL" ]; then
45
echo "\$SGE_ROOT and \$SGE_CELL must be set to valid values"
49
if [ -z "$ARCH" ]; then
50
ARCH=`$SGE_ROOT/util/arch`
53
if [ -z "$V5UTILBIN" ]; then
54
V5UTILBIN=$SGE_ROOT/utilbin/$ARCH # adminrun, infotext, openssl, uidgid
57
if [ ! -d "$V5UTILBIN" ]; then
59
echo "Error: The utilbin directory "$V5UTILBIN" does not exist"
60
echo "Please verify your setup and restart this script. Exit."
64
if [ -z "$INFOTEXT" ]; then
65
INFOTXT_DUMMY=$V5UTILBIN/infotext
66
INFOTEXT=$INFOTXT_DUMMY
67
if [ ! -x $INFOTXT_DUMMY ]; then
68
echo "Error: Can't find binary \"$INFOTXT_DUMMY\""
69
echo "Please verify your setup and restart this script. Exit."
73
# Test the infotext binary
74
tmp=`$INFOTEXT test 2>&1`
76
echo "Error: Execution of $INFOTEXT failed: $tmp"
77
echo "Please verify your setup and restart this script. Exit."
81
SGE_INFOTEXT_MAX_COLUMN=5000; export SGE_INFOTEXT_MAX_COLUMN
84
# ST are supported just on linux and solaris
90
$INFOTEXT "The service tags are not supported"
100
#---------------------------------------------------------------------------
101
# show the usage of the standalone command
102
# if ADMINUSER = default then execute command unchanged
105
$INFOTEXT "sge_st enable|disable|register|unregister|check|enabled|supported|help"
106
$INFOTEXT " -------------------------------------------------------------------------------"
107
$INFOTEXT " enable ... enable The Service Tags"
108
$INFOTEXT " disable ... disable The Service Tags"
109
$INFOTEXT " register ... register product"
110
$INFOTEXT " unregister . unregister product"
111
$INFOTEXT " check ... check if the product is registered"
112
$INFOTEXT " enabled ... check if the Service Tags are enabled"
113
$INFOTEXT " supported .. check if the Service Tags packages are installed on host"
114
$INFOTEXT " help ... this help"
117
#-------------------------------------------------------------------------
118
#arch_variables Setting up common variables and paths
122
if [ -f "$SGE_ROOT/util/arch_variables" ]; then
123
. $SGE_ROOT/util/arch_variables
125
$INFOTEXT "Could not source arch_variables"
130
#-------------------------------------------------------------------------
131
#Service Tags Setting up
136
if [ -f "$SGE_ROOT/util/sgeST/st_settings.sh" ]; then
137
. $SGE_ROOT/util/sgeST/st_settings.sh
139
$INFOTEXT "Could not source basic settings"
144
#---------------------------------------------------------------------------
145
# Test the instance_urn is valid
146
# urn should start with urn:st
147
# USES: parameter $1 "instance_urn"
148
# Return "true" / "false" to strdout
150
STvalidateInstanceUrn()
154
instance_urn_valid=`echo "$1" | $CUT -f1-2 -d:`
155
if [ "$instance_urn_valid" = "urn:st" ]; then
162
#---------------------------------------------------------------------------
163
# The Service Tags Enabled Test
164
# Return true if the st.enabled file is present
166
# Return "true", the ST are enabled, "false" ST are not enabled
169
st_file=$SGE_ROOT/$SGE_CELL/common/st.enabled
170
if [ -f "$st_file" ]; then
177
#---------------------------------------------------------------------------
178
# Enable the service tegs
181
st_file=$SGE_ROOT/$SGE_CELL/common/st.enabled
182
if [ ! -f "$st_file" ]; then
183
CreateAndMakeWriteable $st_file
184
echo $PRODUCT_URN >> $st_file
185
result=`STShowEnabled`
186
if [ $result = "true" ]; then
187
$INFOTEXT "Sun Service Tags are now enabled"
189
$INFOTEXT "Sun Service Tags could not be enabled"
196
#---------------------------------------------------------------------------
197
# Disable The Service Tags
201
st_file=$SGE_ROOT/$SGE_CELL/common/st.enabled
202
if [ -f "$st_file" ]; then
203
ExecuteAsAdmin $RM $st_file
204
result=`STShowEnabled`
205
if [ $result = "false" ]; then
206
$INFOTEXT "Sun Service Tags are now disabled"
208
$INFOTEXT "Sun Service Tags could not be disabled"
215
#---------------------------------------------------------------------------
216
# Get the product instance_URN from ST registry
217
# using the find all instances of the product function
220
# $product_defined_id
221
# return $instance_urn to stdout
225
product_defined_id=$2
227
#find first product instance with the same product_defined_inst_id
228
urn_list=`$stclient -f -t "$PRODUCT_URN"`
229
for registered_urn in $urn_list ;do
230
valid=`STvalidateInstanceUrn $registered_urn`
231
if [ $valid = "true" ]; then
232
registered_inst_id=`$stclient -g -i $registered_urn | grep product_defined_inst_id | $CUT -f2 -d=`
233
if [ "$registered_inst_id" = "$product_defined_id" ]; then
234
instance_urn=$registered_urn
243
#---------------------------------------------------------------------------
244
# Test the stclient is valid and installed
246
# return stclient or "undefined" if not stclient
248
STgetServiceTagClient()
250
if [ -z "$stclient" ]; then
251
# library path setting required only for architectures where RUNPATH is not supported
254
stclient=`rpm -ql sun-servicetag 2>/dev/null | grep bin/stclient`
257
# a strange error message comes from pkgchk -l, need to be filtered out
258
if [ -x /usr/bin/stclient ]; then
259
stclient=/usr/bin/stclient
264
if [ -z "$stclient" ]; then
270
#---------------------------------------------------------------------------
271
# Sub function create st client
272
# return registered or not to stdout
275
#get the stclinet with full path
276
stclient=`STgetServiceTagClient`
277
if [ "$stclient" = "undefined" ]; then
278
$INFOTEXT "The service tags are not supported"
281
#the executeble file must exist
282
if [ ! -x "$stclient" ]; then
283
$INFOTEXT "The service tags are not installed correctly"
291
#---------------------------------------------------------------------------
292
# The Service Tags Packages are installed on the node
294
# Return "true", the ST are supported, "false" ST are not supported
297
#get the stclinet with full path
298
stclient=`STgetServiceTagClient`
299
if [ "$stclient" = "undefined" ]; then
302
#the executable file must exist
303
if [ -x "$stclient" ]; then
311
#---------------------------------------------------------------------------
312
# Get the product instance_URN from ST registry
313
# using the find all instances of the product function
315
# PARAMS: $product_defined_id
316
# return registered or unregistered
319
product_defined_id=$1
323
#check again, to be sure wos done
324
instance_urn=`STgetInstanceUrn "$stclient" "$product_defined_id"`
325
if [ -n "$instance_urn" ]; then
326
$INFOTEXT "registered:%s" "$instance_urn"
328
$INFOTEXT "unregistered"
333
#---------------------------------------------------------------------------
334
# Add a new instance of product to a ST registry
335
# using the platform CLI command
336
# Add only if $instance_urn is empty
338
# ARGS: $stclient CLI tool
340
# $product_defined_id
346
product_defined_id=$3
347
if [ -z "$instance_urn" ]; then
348
platform_name=`uname -p`
357
if [ -x /usr/bin/zonename ]; then
358
zone=`/usr/bin/zonename`
363
ExecuteAsAdmin ${stclient} -a \
364
-p "${PRODUCT_NAME}" \
365
-e "${PRODUCT_VERSION}" \
366
-t "${PRODUCT_URN}" \
367
-P "${PRODUCT_PARENT_NAME}" \
368
-I "${product_defined_id}" \
369
-m "${PRODUCT_VENDOR}" \
370
-A "${platform_name}" \
372
-S "${PRODUCT_SOURCE}" > /dev/null 2>&1
376
#---------------------------------------------------------------------------
377
# Remove instance of product to a ST registry
378
# using the platform CLI command
379
# Remove only if $instance_urn is not empty
381
# USES: $stclient CLI tool
388
if [ -n "$instance_urn" ]; then
389
ExecuteAsAdmin $stclient -d -i "$instance_urn" > /dev/null 2>&1
393
#---------------------------------------------------------------------------
394
# show the usage of the standalone command
395
# PARAMS: $product_defined_id
396
# return registered or not to stdout
399
product_defined_id=$1
401
#get the stclinet with full path
407
instance_urn=`STgetInstanceUrn "$stclient" "$product_defined_id"`
408
STaddServiceTag "$stclient" "$instance_urn" "$product_defined_id"
409
STShowRegistered "$product_defined_id"
414
#---------------------------------------------------------------------------
415
# show the usage of the standalone command
416
# PARAMS: $product_defined_id
417
# return registered or not to stdout
420
product_defined_id=$1
425
instance_urn=`STgetInstanceUrn "$stclient" "$product_defined_id"`
426
STremoveServiceTag "$stclient" "$instance_urn"
427
STShowRegistered "$product_defined_id"
431
#---------------------------------------------------------------------------
434
# check ... called from install script
435
# return a customer stdout output
439
if [ "$#" -lt 1 -o "$#" -gt 2 -o "$command" = "-h" -o "$command" = "help" ]; then
444
#Architecture related variables
448
#load static data from file
450
#redefine dynamic data for instalation
451
product_defined_id=$SGE_ROOT/$SGE_CELL
453
if [ "$command" = "enable" ]; then
455
elif [ "$command" = "disable" ]; then
457
elif [ "$command" = "register" ]; then
458
STRegister "$product_defined_id"
459
elif [ "$command" = "unregister" ]; then
460
STUnregister "$product_defined_id"
461
elif [ "$command" = "enabled" ]; then
463
elif [ "$command" = "supported" ]; then
465
elif [ "$command" = "check" ]; then
466
STShowRegistered "$product_defined_id"