3 # Copyright (c) 2007 by Sun Microsystems, Inc.
7 if [ `uname -s` = "SunOS" ]; then
8 STCLIENT
=/usr
/bin
/stclient
10 STCLIENT
=/opt
/sun
/servicetag
/bin
/stclient
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;;
32 "usage: $0 -p <product name> -e <product version> -t <urn> -S <source> -P <parent product name> [-i <instance urn>]"
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
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