#!/bin/sh # # Copyright (C) 2012 Red Hat, Inc. All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # Authors: Radek Novacek # pegasus_repository="/var/lib/Pegasus/repository" function usage() { printf "Usage: $0 [ register | unregister ] mof reg\n" } function register() { mof=$1 reg=$2 if [ $HAS_SFCBD -eq 1 ]; then /usr/bin/sfcbstage -r $reg $mof /usr/bin/sfcbrepos -f /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service fi if [ $HAS_PEGASUS -eq 1 ]; then /usr/sbin/cimserver --status > /dev/null 2>&1 if [ $? -eq 0 ]; then CIMMOF="/usr/bin/cimmof" else CIMMOF="/usr/bin/cimmofl -R $pegasus_repository" fi $CIMMOF -uc $mof if [ -x $(dirname $0)/openlmi-register-pegasus ]; then cat $reg | $(dirname $0)/openlmi-register-pegasus | $CIMMOF -uc -n root/PG_Interop else cat $reg | /usr/libexec/openlmi-register-pegasus | $CIMMOF -uc -n root/PG_Interop fi fi } function unregister() { mof=$1 reg=$2 if [ $HAS_SFCBD -eq 1 ]; then /usr/bin/sfcbunstage -r $(basename $reg) $(basename $mof) /usr/bin/sfcbrepos -f /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service fi if [ $HAS_PEGASUS -eq 1 ]; then for provider in $(sed -n 's/ *location: *//p' $reg | sort | uniq); do /usr/bin/cimprovider -d -m ${provider} && /usr/bin/cimprovider -r -m ${provider} done fi } if [ $# -lt 3 ]; then usage exit 1 fi if [ -e /usr/sbin/sfcbd ]; then HAS_SFCBD=1 else HAS_SFCBD=0 fi if [ -e /usr/sbin/cimserver ]; then HAS_PEGASUS=1 else HAS_PEGASUS=0 fi # TODO: check if at least one server is installed case $1 in register) register $2 $3 break;; unregister) unregister $2 $3 break;; **) usage exit 1 esac