# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1197066990 28800
# Node ID 0d80882209b4002da9283e4cfe17d48cb1155d45
# Parent 588daf25941e36b540689209bf0c76b1ce08cb32
Add base schema installation script
Changes:
- Removed explicit -x
- Added optional -x and debug dump based on environment variable
- Fixed cimv*.mof ambiguity
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 588daf25941e -r 0d80882209b4 base_schema/install_base_schema.sh.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/base_schema/install_base_schema.sh.in Fri Dec 07 14:36:30 2007 -0800
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+DATA="$1"
+NS=@CIM_VIRT_NS@
+CIMOM=@CIMSERVER@
+
+TMPDIR=$(mktemp -d /tmp/cim_schema.XXXXX)
+
+if [ ! -z "$CIM_DEBUG" ]; then
+ set -x
+ DEBUG="$TMPDIR/log"
+else
+ DEBUG="/dev/null"
+fi
+
+unpack_schema() {
+ cd ${TMPDIR} && unzip ${DATA}/cimv*-MOFs.zip
+}
+
+fix_schema() {
+ (cd ${TMPDIR} && patch -p0 < ${DATA}/fix_schema.patch)
+ cp -a ${DATA}/cimv216-interop_mof ${TMPDIR}/cimv216-interop.mof
+}
+
+detect_peg_repo() {
+ dirs="$PEGASUS_HOME /var/lib/Pegasus /var/lib/pegasus /usr/local/var/lib/pegasus
/var/local/lib/pegasus /var/opt/tog-pegasus"
+
+ for d in $dirs; do
+ if [ -d "$d" ]; then
+ echo $d
+ return
+ fi
+ done
+}
+
+detect_sfcb_dir() {
+ dirs="SFCB_DIR /usr/local/share/sfcb /usr/share/sfcb"
+
+ for d in $dirs; do
+ if [ -d "$d" ]; then
+ echo $d;
+ return
+ fi
+ done
+}
+
+install_schema_pegasus() {
+ local repo=$(detect_peg_repo)
+
+ if [ -z "$repo" ]; then
+ echo "Unable to determine Pegasus repository path"
+ echo "set PEGASUS_HOME"
+ return
+ fi
+
+ cd ${TMPDIR}
+
+ cimmofl -uc -aEV -R$repo -n $NS cimv???.mof
+ cimmofl -uc -aEV -R$repo -n $NS qualifiers.mof
+ cimmofl -uc -aEV -R$repo -n $NS qualifiers_optional.mof
+ cimmofl -uc -aEV -R$repo -n /root/interop cimv???-interop.mof
+}
+
+install_schema_sfcb() {
+ local dir=$(detect_sfcb_dir)
+
+ if [ ! mkdir ${dir}/CIM ]; then
+ echo "Unable to determine SFCB directory"
+ echo "set SFCB_DIR"
+ return
+ fi
+
+ mv ${TMPDIR}/cimv???.mof ${TMPDIR}/CIM_Schema.mof
+ cp -ra ${TMPDIR}/* ${dir}
+ sfcbrepos
+}
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 [source_dir]"
+ exit 1
+fi
+
+(unpack_schema) >>$DEBUG 2>&1
+(fix_schema) >>$DEBUG 2>&1
+
+case "$CIMOM" in
+ sfcb)
+ (install_schema_sfcb) >>$DEBUG 2>&1
+ ;;
+ pegasus)
+ (install_schema_pegasus) >>$DEBUG 2>&1
+ ;;
+ *)
+ echo ERROR: Unknown CIMOM: $CIMOM
+ ;;
+esac
+
+if [ -f "$DEBUG" ]; then
+ echo "-- base schema install log begin --"
+ cat $DEBUG
+ echo "-- base schema install log end --"
+fi
\ No newline at end of file