#!/bin/ksh

#
# If there was an fmd service registered on the system, we disabled it.  Now
# that we're done backing out this patch, we need to re-enable it.  Note that
# we don't make any attempt to determine whether it had been disabled before
# we disabled for patching.  fmd is a critical system service, and shouldn't
# be disabled by users.
#

SVCNAME=svc:/system/fmd:default

if [ "$ROOTDIR" != "/" ] ; then
        # This patch is being applied to an alternate root, which means that
        # we weren't patching objects belonging to a running fmd.  As such,
        # we didn't disable anything, and don't need to re-enable anything.
        exit 0
fi

if ! svcs $SVCNAME >/dev/null 2>&1 ; then
        # fmd isn't registered as a service on this machine.  We won't attempt
        # to re-enable it.
        exit 0
fi

echo 'Re-enabling fmd(1M)'
svcadm enable $SVCNAME
if [ $? -ne 0 ] ; then
        echo "failed to re-enable fmd service after patch" >&2
        exit 1
fi

exit 0
