1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/bin/sh
#Script to fetch CIM schema for sfcb.
# Evaluate the CIMSCHEMA_ env vars, if not set
# use the configure values, if available
# defaults otherwise
CIMSCHEMA_SOURCE=${CIMSCHEMA_SOURCE:-@CIMSCHEMA_SOURCE@}
CIMSCHEMA_MOF=${CIMSCHEMA_MOF:-@CIMSCHEMA_MOF@}
CIMSCHEMA_SUBDIRS=${CIMSCHEMA_SUBDIRS:-@CIMSCHEMA_SUBDIRS@}
MOFZIPURL=${CIMSCHEMA_SOURCE:-"http://www.dmtf.org/standards/cim/cim_schema_v217/cimv217Final-MOFs.zip"}
SCHEMAMOF=${CIMSCHEMA_MOF:-cimv217.mof}
# zip file for schema v2.17 (and others) contain subdirectories. v2.9 does not
HASSUBDIRS=yes
if [ $CIMSCHEMA_SUBDIRS = no ]
then
HASSUBDIRS=no
fi
TMPZIP=/tmp/cimmof.zip
trap "rm -f $TMPZIP" exit
usage()
{
echo usage: $1 [-f] [schemadir] >&2
}
fixschema()
{
cd $sfcbdir/CIM
if [ $SCHEMAMOF != CIM_Schema.mof ]
then
cp $SCHEMAMOF CIM_Schema.mof
fi
}
args=`getopt f $*`
rc=$?
if [ $rc = 127 ]
then
echo "warning: getopt not found ...continue without syntax check"
args=$*
elif [ $rc != 0 ]
then
usage $0
exit 1
fi
set -- $args
force=0
while [ -n "$1" ]
do
case $1 in
-f) force=1
shift;;
--) shift;
break;;
esac
done
if [ $# = 1 ]; then
sfcbdir=$1
elif [ $# = 0 ]; then
sfcbdir=@datadir@/sfcb
else
usage $0
exit 1
fi
fetch_mof()
{
if echo $MOFZIPURL | grep http: > /dev/null
then
if [ -x /usr/bin/curl ]
then
/usr/bin/curl -o $TMPZIP $MOFZIPURL
else
echo "Need curl to get CIM schema files." 1>&2
return 1
fi
else
cp $MOFZIPURL $TMPZIP
fi
}
if [ ! -f $sfcbdir/CIM/CIM_Schema.mof ] || [ $force = 1 ]
then
echo "Fetching CIM Schema from $MOFZIPURL ..."
if [ -d $sfcbdir/CIM ]
then
rm -rf $sfcbdir/CIM
if [ $? != 0 ]
then
echo "Failed to delete schema directory $sfcbdir/CIM" >&2
exit 1
fi
fi
mkdir -p $sfcbdir/CIM
if [ $HASSUBDIRS = yes ]
then
ZIPFLAGS=
else
ZIPFLAGS=-j
fi
if [ $? = 0 ]; then
fetch_mof &&
unzip $ZIPFLAGS -d $sfcbdir/CIM $TMPZIP &&
fixschema &&
exit 0
fi
echo "Failed to fetch and install CIM schema" 1>&2
else
echo "CIM Schema already present - nothing to do."
exit 0
fi
|