#!/bin/ksh

#
# We need to take special care when updating fmd to ensure that the daemon
# always sees a consistent view of the world.  To do that, we temporarily
# disable fmd while patching.  When patching is complete, we re-enable it.
#

SVCNAME=svc:/system/fmd:default

if [ "$ROOTDIR" != "/" ]; then
# This patch is being applied to an alternate root, which means that
# we're not patching objects belonging to a running fmd.
exit 0
fi

if ! svcs $SVCNAME >/dev/null 2>&1 ; then
# fmd isn't registered as a service on this machine, which is
# strange.  Don't attempt to disable it.
exit 0
fi

echo 'Temporarily disabling fmd(1M)'
svcadm disable -t -s $SVCNAME
if [ $? -ne 0 ] ; then
echo "failed to disable fmd service for patch" >&2
exit 1
fi

exit 0
