summaryrefslogtreecommitdiffstats
path: root/openlmi-mof-register
diff options
context:
space:
mode:
Diffstat (limited to 'openlmi-mof-register')
-rwxr-xr-xopenlmi-mof-register55
1 files changed, 43 insertions, 12 deletions
diff --git a/openlmi-mof-register b/openlmi-mof-register
index e322664..d7918e0 100755
--- a/openlmi-mof-register
+++ b/openlmi-mof-register
@@ -20,13 +20,16 @@
#
pegasus_repository="/var/lib/Pegasus/"
+default_namespace="root/cimv2"
function usage()
{
- printf "Usage: $0 [ --just-mofs ] CMD <mof> [mof] [...] [reg]
+ printf "Usage: $0 [ --just-mofs ] [ -n namespace ] CMD <mof> [mof] [...] [reg]
CMD is one of [ register, unregister ]
- just-mofs option causes that all arguments after CMD will be
+ Default namespace is $default_namespace, which can be changed with '-n' option.
+
+ --just-mofs option causes that all arguments after CMD will be
treated as mof files - no registration file is expected.
usage with --just-mofs:
@@ -55,9 +58,9 @@ function register()
/usr/sbin/cimserver --status > /dev/null 2>&1
if [ $? -eq 0 ];
then
- CIMMOF="/usr/bin/cimmof -aEV"
+ CIMMOF="/usr/bin/cimmof -aEV -n $namespace"
else
- CIMMOF="/usr/bin/cimmofl -aEV -R $pegasus_repository"
+ CIMMOF="/usr/bin/cimmofl -aEV -R $pegasus_repository -n $namespace"
fi
$CIMMOF -uc $mofs
@@ -100,7 +103,42 @@ function unregister()
fi
}
-if [ $# -lt 3 ];
+JUST_MOFS=0
+optspec=":hn:-:"
+
+while getopts "$optspec" optchar; do
+ case "$optchar" in
+ -) # long options parsing
+ case "$OPTARG" in
+ just-mofs)
+ JUST_MOFS=1
+ ;;
+ *)
+ if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
+ echo "Unknown option --${OPTARG}" >&2
+ fi
+ ;;
+ esac
+ ;;
+ n)
+ namespace="$OPTARG"
+ ;;
+ h)
+ usage;
+ exit 0;
+ ;;
+ *)
+ if [ "$OPTERR" != 1 ] || [ "${optspec:0:1}" = ":" ]; then
+ echo "Non-option argument: '-${OPTARG}'" >&2
+ fi
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+namespace=${namespace:-$default_namespace}
+
+if [ $# -lt 2 ];
then
usage
exit 1
@@ -121,13 +159,6 @@ else
fi
# TODO: check if at least one server is installed
-
-if [ "$1" = "--just-mofs" ]; then
- JUST_MOFS=1
- shift
-else
- JUST_MOFS=0
-fi
CMD=$1
shift