blob: a495415be523798f70365be15fe2d7ad289ead6b [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001#!/bin/sh
2#
3# options:
4# rmmof.sh <MOF_PATH> <NAMESPACE> <FILES>
5#
6# - or -
7#
8# options:
9# loadmof.sh -n <NAMESPACE> <FILES> [...]
10#
11# The former is preserved for compatibility with Pegasus and
12# sblim providers. The latter is preferred. If $1 is "-n",
13# the latter code path is executed. Otherwise the former is
14# executed.
15
16if [ "x$3" = "x" ]; then
17 echo "Usage: $0 -n <NAMESPACE> <FILES> [...]"
18 exit 1
19fi
20
21# get rid of "-n" arg
22shift
23
24NS="$1"
25
26shift
27
28DBDIR=/var/lib/openwbem
29CIMOM_INIT=/etc/init.d/owcimomd
30if [ "$YAST_IS_RUNNING" != "instsys" ] ; then
31 $CIMOM_INIT status
32 CIMOM_RUNNING=$?
33fi
34if [ "x$CIMOM_RUNNING" = "x0" ]; then
35 $CIMOM_INIT stop
36fi
37bkpdir=/tmp/owrep.bkp-$$
38mkdir $bkpdir
39cp -a $DBDIR $bkpdir/
40echo "Compiling MOF files"
41/usr/bin/owmofc -r -n $NS -d $DBDIR "$@" > /dev/null 2>&1
42RVAL=$?
43if [ "x$RVAL" != "x0" ]; then
44 echo "MOF import failed!"
45 rm -rf $DBDIR
46 mv $bkpdir/openwbem $DBDIR
47fi
48rm -rf $bkpdir
49if [ "x$CIMOM_RUNNING" = "x0" ]; then
50 $CIMOM_INIT start
51fi
52exit $RVAL
53