#!/bin/sh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/lpp/bosinst/samples/AE/ae.sh 1.1 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2008,2009 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)22 1.1 src/bos/usr/lpp/bosinst/samples/AE/ae.sh, bosinst, bos720 3/29/09 15:14:03 # This is the Activation Engine. It is installed on a virtual machine # template to provides a simple interface to run activation scripts # during the boot up sequence. When the template is cloned, they will # run at boot, look for a floppy disk containing the options for each # activation script, and run just once. PERL_BIN="/usr/bin/perl" TEMPCONF="/tmp/tempconf" ECHOE="echo -e" UNAME=`uname -s`; if [ "$UNAME" = "AIX" ] then ECHOE="echo" fi #---------------functions-----------------# usage() { $ECHOE "Usage: sh $0 OPTION [FILE]\n" $ECHOE " -a AL_FILE\t\t\tCreate Multiple Services" $ECHOE " -r AL_FILE\t\t\tRemove Multiple Services" # $ECHOE " -fa AL_FILE\t\t\tCreate Single Service" # $ECHOE " -fr AL_FILE\t\t\tRemove Single Service" $ECHOE " -i [AP_FILE]\t\t\tActivate interactively" # $ECHOE " -f [AP_FILE]\t\t\tActivate forcibly" $ECHOE " -s RESOURCENAME CONFIGNAME\t\t\tActivate by service" } # get the full path of script and parameter getScriptFullPath() { DIR="" NAME="" CHK=`$ECHOE $0|grep '^/'` if [ ! -z "$CHK" ]; then DIR=`dirname $0` NAME=`basename $0` else DIR=`pwd`"/"`dirname $0` NAME=`basename $0` fi echo "$DIR/$NAME" } getParameterFullPath() { FPATH="" CHK=`$ECHOE "$1"|grep '^/'` if [ -z "$CHK" ]; then FPATH=`pwd`"/$1" else FPATH=$1 fi echo "$FPATH" } #extract configuration elements extractConfFromAL() { cp $1 $TEMPCONF #cat "$1" |grep " $TEMPCONF } extractResrcName(){ $ECHOE "$1" | sed "s/.*software-resource name=\"//g" | sed "s/\".*//g" } extractConfName() { $ECHOE "$1" | sed "s/.*configuration name=\"//g" | sed "s/\".*//g" } #clean AR cleanAR() { rm -rf ${AE_DIR}/AR/* } # excute every service forcibly. executeForcely() { counter=1 rsrcName="" while : do loopstr=`sed -n "${counter}p" $TEMPCONF` if [ -z "$loopstr" ]; then $ECHOE "$0: Activation Done" break else case $loopstr in *\/dev/null 2>/dev/null cd "savedPath" fi else usage exit -1 fi cleanAR AP=`find ${AE_DIR}/AP -name "ovf-env.xml" -print` if [ ! -e "$AP" ] then AP=`find ${AE_DIR}/AP -name "*.ap" -print`; fi test -f "$AP" || { $ECHOE "AP file is not found." exit -1 } extractConfFromAL "$AL" if [ ! -f "$TEMPCONF" ]; then $ECHOE "$0: $TEMPCONF is not created." exit -1 fi executeForcely rm -rf "$TEMPCONF" ;; -i) # Activate interactively if [ $# -eq 1 ]; then AL=`find ${AE_DIR}/AL -name "master.al" -print`; test -f "$AL" || { $ECHOE "AL file is not found." exit -1 } elif [ $# -eq 2 ]; then AL=`find ${AE_DIR}/AL -name "master.al" -print`; test -f "$AL" || { $ECHOE "AL file is not found." exit -1 } apSrc="$2" if [ -f "$apSrc" ]; then #local path, copy cp "$apSrc" ${AE_DIR}/AP else #remote path, download rm -rf ${AE_DIR}/AP/* savedPath=`pwd` cd ${AE_DIR}/AP wget "$apSrc" 1>/dev/null 2>/dev/null cd "savedPath" fi else usage exit -1 fi cleanAR AP=`find ${AE_DIR}/AP -name "ovf-env.xml" -print` if [ ! -e "$AP" ] then AP=`find ${AE_DIR}/AP -name "*.ap" -print` fi test -f "$AP" || { $ECHOE "AP file is not found." exit -1 } extractConfFromAL "$AL" if [ ! -f "$TEMPCONF" ]; then $ECHOE "$0: $TEMPCONF is not created." exit -1 fi executeInteractively rm -rf "$TEMPCONF" ;; *) usage ;; esac #--------This is end of script--------#