summaryrefslogtreecommitdiffstats
path: root/openlmi-mof-register
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2013-08-01 15:06:00 +0200
committerRadek Novacek <rnovacek@redhat.com>2013-08-02 10:06:20 +0200
commit226fceeaa78adbeef9bbf67fbcf789b93bfb7bf4 (patch)
treea623160971a91cb895a8c54cef53615d8ebf2b5c /openlmi-mof-register
parent3b6769a3677990cc2df079dc34feefce5111b16f (diff)
downloadopenlmi-providers-226fceeaa78adbeef9bbf67fbcf789b93bfb7bf4.zip
openlmi-providers-226fceeaa78adbeef9bbf67fbcf789b93bfb7bf4.tar.gz
openlmi-providers-226fceeaa78adbeef9bbf67fbcf789b93bfb7bf4.tar.xz
Add logging to the openlmi-mof-register script
Each command in the registration script is now logged into /var/log/openlmi-install.log file.
Diffstat (limited to 'openlmi-mof-register')
-rwxr-xr-xopenlmi-mof-register46
1 files changed, 36 insertions, 10 deletions
diff --git a/openlmi-mof-register b/openlmi-mof-register
index 4e60e31..6107503 100755
--- a/openlmi-mof-register
+++ b/openlmi-mof-register
@@ -23,10 +23,27 @@
pegasus_repository="/var/lib/Pegasus/"
default_namespace="root/cimv2"
+function log()
+{
+ printf "%(%Y-%m-%d %H:%M:%S)T " -1 >&2
+ printf "$*\n" >&2
+}
+
+function log_command()
+{
+ log "COMMAND:" "$*" >&2
+ "$@"
+ code=$?
+ log "EXIT CODE:" "$code" >&2
+ return $code
+}
+
+trap 'log "DONE WITH EXIT CODE:" "$?"' EXIT
+
function start_pegasus()
{
# Start Pegasus CIMOM in restricted mode, listening only on its unix socket
- /usr/sbin/cimserver daemon=true \
+ log_command /usr/sbin/cimserver daemon=true \
enableHttpConnection=false \
enableHttpsConnection=false \
enableRemotePrivilegedUserAccess=false \
@@ -40,7 +57,7 @@ function start_pegasus()
function stop_pegasus()
{
- /usr/sbin/cimserver -s
+ log_command /usr/sbin/cimserver -s
}
function usage()
@@ -76,9 +93,9 @@ function register()
mofs="$@"
if [ $HAS_SFCBD -eq 1 ] && echo $cimom | grep -q 'all\|sfcbd';
then
- /usr/bin/sfcbstage -n $namespace ${reg:+-r} $reg $mofs
- /usr/bin/sfcbrepos -f
- /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
+ log_command /usr/bin/sfcbstage -n $namespace ${reg:+-r} $reg $mofs
+ log_command /usr/bin/sfcbrepos -f
+ log_command /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
fi
if [ $HAS_PEGASUS -eq 1 ] && echo $cimom | grep -q 'all\|tog-pegasus';
@@ -91,13 +108,17 @@ function register()
CIMMOF="/usr/bin/cimmofl -aEV -R $pegasus_repository -n $namespace"
fi
- $CIMMOF -uc $mofs
+ log_command $CIMMOF -uc $mofs
if [ $JUST_MOFS -eq 0 ]; then
if [ -x $(dirname $0)/openlmi-register-pegasus ];
then
+ log "COMMAND: cat \"$reg\" | $(dirname $0)/openlmi-register-pegasus -v \"$version\" | $CIMMOF -uc -n root/interop"
cat "$reg" | $(dirname $0)/openlmi-register-pegasus -v "$version" | $CIMMOF -uc -n root/interop
+ log "EXIT CODE:" "$?"
else
+ log "COMMAND: cat \"$reg\" | /usr/libexec/openlmi-register-pegasus -v \"$version\" | $CIMMOF -uc -n root/interop"
cat "$reg" | /usr/libexec/openlmi-register-pegasus -v "$version" | $CIMMOF -uc -n root/interop
+ log "EXIT CODE:" "$?"
fi
fi
fi
@@ -118,9 +139,9 @@ function unregister()
for ((i=0; i<${#mofs[@]}; i++)); do
bmofs[$i]=$(basename "${mofs[$i]}")
done
- /usr/bin/sfcbunstage -n $namespace ${reg:+-r} $(basename "$reg") ${bmofs[@]}
- /usr/bin/sfcbrepos -f
- /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
+ log_command /usr/bin/sfcbunstage -n $namespace ${reg:+-r} $(basename "$reg") ${bmofs[@]}
+ log_command /usr/bin/sfcbrepos -f
+ log_command /usr/bin/systemctl reload-or-try-restart sblim-sfcb.service
fi
if [ $HAS_PEGASUS -eq 1 ] && echo $cimom | grep -q 'all\|tog-pegasus';
@@ -139,7 +160,8 @@ function unregister()
fi
for provider in $providers;
do
- /usr/bin/cimprovider -d -m ${provider} && /usr/bin/cimprovider -r -m ${provider}
+ log_command /usr/bin/cimprovider -d -m ${provider}
+ log_command /usr/bin/cimprovider -r -m ${provider}
done
fi
mofcomp -n $namespace -r ${mofs[@]}
@@ -149,6 +171,8 @@ function unregister()
fi
}
+log "STARTING" "$0" "$@"
+
JUST_MOFS=0
optspec=":hn:c:v:-:"
@@ -262,3 +286,5 @@ case $CMD in
usage
exit 1
esac
+
+exit 0