Update ooo320-m1
[ooovba.git] / setup_native / scripts / stclient_wrapper.sh
blobafe9515a10fb2be601fe655dafd5d9a6f19eb400
1 #!/bin/sh
3 # Copyright (c) 2007 by Sun Microsystems, Inc.
4 # All rights reserved.
7 if [ `uname -s` = "SunOS" ]; then
8 STCLIENT=/usr/bin/stclient
9 else
10 STCLIENT=/opt/sun/servicetag/bin/stclient
13 TARGET_URN=
14 PRODUCT_NAME=
15 PRODUCT_VERSION=
16 PRODUCT_SOURCE=
17 PARENT_PRODUCT_NAME=
18 INSTANCE_URN=
20 while [ $# -gt 0 ]
22 case "$1" in
23 -t) TARGET_URN="$2"; shift;;
24 -p) PRODUCT_NAME="$2"; shift;;
25 -e) PRODUCT_VERSION="$2"; shift;;
26 -i) INSTANCE_URN="$2"; shift;;
27 -P) PARENT_PRODUCT_NAME="$2"; shift;;
28 -S) PRODUCT_SOURCE="$2"; shift;;
29 --) shift; break;;
30 -*)
31 echo >&2 \
32 "usage: $0 -p <product name> -e <product version> -t <urn> -S <source> -P <parent product name> [-i <instance urn>]"
33 exit 1;;
34 *) break;;
35 esac
36 shift
37 done
39 [ -x "$STCLIENT" ] || exit 1
41 # test if already registered
42 if [ ! -n $INSTANCE_URN ]; then
43 TEST=`${STCLIENT} -f -t ${TARGET_URN}`; EXITCODE=$?
45 # retry on unexpected error codes
46 [ ${EXITCODE} -eq 0 -o ${EXITCODE} -eq 225 ] || exit 1
48 # early versions did not have a dedicated exitcode, so need to compare text output
49 [ ${EXITCODE} -eq 225 -o "${TEST}" = "No records found" ] || echo "${TEST}"; exit 0
52 uname=`uname -p`
53 zone="global"
55 if [ `uname -s` = "SunOS" ]; then
56 if [ -x /usr/bin/zonename ]; then
57 zone=`/usr/bin/zonename`
61 output=`"${STCLIENT}" -a -p "${PRODUCT_NAME}" -e "${PRODUCT_VERSION}" -t ${TARGET_URN} -S "${PRODUCT_SOURCE}" -P "${PARENT_PRODUCT_NAME}" ${INSTANCE_URN:+"-i"} ${INSTANCE_URN} -m "Sun Microsystems, Inc." -A "${uname}" -z "${zone}"`; EXITCODE=$?
63 [ "${INSTANCE_URN}" = "" -a ${EXITCODE} -eq 226 ] && exit 0
65 exit ${EXITCODE}