1*cdf0e10cSrcweir#!/bin/sh 2*cdf0e10cSrcweir# 3*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 4*cdf0e10cSrcweir# All rights reserved. 5*cdf0e10cSrcweir# 6*cdf0e10cSrcweir 7*cdf0e10cSrcweirif [ `uname -s` = "SunOS" ]; then 8*cdf0e10cSrcweir STCLIENT=/usr/bin/stclient 9*cdf0e10cSrcweirelse 10*cdf0e10cSrcweir STCLIENT=/opt/sun/servicetag/bin/stclient 11*cdf0e10cSrcweirfi 12*cdf0e10cSrcweir 13*cdf0e10cSrcweirTARGET_URN= 14*cdf0e10cSrcweirPRODUCT_NAME= 15*cdf0e10cSrcweirPRODUCT_VERSION= 16*cdf0e10cSrcweirPRODUCT_SOURCE= 17*cdf0e10cSrcweirPARENT_PRODUCT_NAME= 18*cdf0e10cSrcweirINSTANCE_URN= 19*cdf0e10cSrcweir 20*cdf0e10cSrcweirwhile [ $# -gt 0 ] 21*cdf0e10cSrcweirdo 22*cdf0e10cSrcweir case "$1" in 23*cdf0e10cSrcweir -t) TARGET_URN="$2"; shift;; 24*cdf0e10cSrcweir -p) PRODUCT_NAME="$2"; shift;; 25*cdf0e10cSrcweir -e) PRODUCT_VERSION="$2"; shift;; 26*cdf0e10cSrcweir -i) INSTANCE_URN="$2"; shift;; 27*cdf0e10cSrcweir -P) PARENT_PRODUCT_NAME="$2"; shift;; 28*cdf0e10cSrcweir -S) PRODUCT_SOURCE="$2"; shift;; 29*cdf0e10cSrcweir --) shift; break;; 30*cdf0e10cSrcweir -*) 31*cdf0e10cSrcweir echo >&2 \ 32*cdf0e10cSrcweir "usage: $0 -p <product name> -e <product version> -t <urn> -S <source> -P <parent product name> [-i <instance urn>]" 33*cdf0e10cSrcweir exit 1;; 34*cdf0e10cSrcweir *) break;; 35*cdf0e10cSrcweir esac 36*cdf0e10cSrcweir shift 37*cdf0e10cSrcweirdone 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir[ -x "$STCLIENT" ] || exit 1 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir# test if already registered 42*cdf0e10cSrcweirif [ ! -n $INSTANCE_URN ]; then 43*cdf0e10cSrcweir TEST=`${STCLIENT} -f -t ${TARGET_URN}`; EXITCODE=$? 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir # retry on unexpected error codes 46*cdf0e10cSrcweir [ ${EXITCODE} -eq 0 -o ${EXITCODE} -eq 225 ] || exit 1 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir # early versions did not have a dedicated exitcode, so need to compare text output 49*cdf0e10cSrcweir [ ${EXITCODE} -eq 225 -o "${TEST}" = "No records found" ] || echo "${TEST}"; exit 0 50*cdf0e10cSrcweirfi 51*cdf0e10cSrcweir 52*cdf0e10cSrcweiruname=`uname -p` 53*cdf0e10cSrcweirzone="global" 54*cdf0e10cSrcweir 55*cdf0e10cSrcweirif [ `uname -s` = "SunOS" ]; then 56*cdf0e10cSrcweir if [ -x /usr/bin/zonename ]; then 57*cdf0e10cSrcweir zone=`/usr/bin/zonename` 58*cdf0e10cSrcweir fi 59*cdf0e10cSrcweirfi 60*cdf0e10cSrcweir 61*cdf0e10cSrcweiroutput=`"${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=$? 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir[ "${INSTANCE_URN}" = "" -a ${EXITCODE} -eq 226 ] && exit 0 64*cdf0e10cSrcweir 65*cdf0e10cSrcweirexit ${EXITCODE} 66*cdf0e10cSrcweir 67