You can also copy the application deployment logic from the installation script of your application and paste the logic into a provisioning component. This option can be used for a tighter integration with Sun OTP provisioning service. In the following example, the application installation script is embedded in its provisioning component.
Example
<?xml version="1.0" encoding="UTF-8"?> <component xmlns='http://www.sun.com/schema/SPS' name='InstallMyComponent' version='5.2.4' description='Install My Component' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' author='OEM Platforms' softwareVendor='Sun Microsystems' path='/com/sun/examples' xsi:schemaLocation='http://www.sun.com/schema/SPS component.xsd'> <extends> <type name='system#container'></type> </extends> <varList> <var name='shell' modifier='FINAL' default='/usr/bin/bash'></var> <var name='installPath' default='/opt' modifier='FINAL'></var> <var name="mediaDirectory" default=":[component:/com/sun/example:mediaDirectory]"/> <var name='postcheck' default='no' prompt="Mark yes if post check required"></var> </varList> <installList> <installSteps returns='false' name='InstallMyComponent' requireLocking='true'> <execNative userToRunAs='root' timeout='7200'> <inputText><![CDATA[ # Example of product installation: # -step 1: initial checks (does product bundle exist?) # -step 2: extraction of bundle into temporary directory # -step 3: invocation of product installer # -step 4: (optional) installation post check (was product installed fine?) # -step 5: temporary files clean up # 1: initial checks scriptPath=:[mediaDirectory]/productName if [ ! -d $scriptPath ]; then echo "Error: $scriptPath does not exist" exit 1 fi if [ ! -f ${scriptPath}/productName.jar ]; then echo "Error: productName.jar does not exist" exit 1 fi # 2a: copy bundle to tmp mkdir -p /tmp/install/productName cp ${scriptPath}/productName.jar /tmp/install/productName cd /tmp/install/productName # 2b: extraction of bundle contents jar xf productName.jar rm -f productName.jar # 3: invoke installer java -cp /tmp/install/productName com.company.product.Boot -p param1 -d param2 -i :[installPath] RET=$?; if [ $RET != 0 ]; then exit $RET; fi # 4: post check if [ "yes" = :[postcheck] ]; then out=`java -cp /tmp/install/productName com.company.product.diagnostics checkInstallation -p param1 \ -d param2 -i :[installPath] | grep "Status=OK"` RET=$?; if [ $RET != 0 ]; then exit $RET; fi fi # 5: cleanup cd / rm -rf /tmp/install/productName ]]></inputText> <exec cmd=':[shell]'></exec> </execNative> </installSteps> </installList> </component>
The embedded code can be any interpreted shell code or Java code. The shell code can be specified by specifying the value for the cmd attribute in the exec element. The embedded Java code can be specified by specifying the execJava element.