#!/bin/bash

#       Copyright (c) Stratus Technologies Bermuda Ltd., 2008.
#       All Rights Reserved. Unpublished rights reserved
#       under the copyright laws of the United States.
# 
#       This program 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; version 2.1 only. with the special
#       exception on linking described in file LICENSE.
#
#       This program 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.

. /usr/libexec/xapi/cluster-stack/xhad/ha_rc

#
#   ha_clear_excluded [-C <config-file-name>]
#

# get config-file name

cf=`getcf $*` || exit $?

# attempt to clear excluded bit through the daemon

calldaemon clear_excluded
status=$?

# if the attempt failed because the daemon is not present,
# then we attempt to update the data on the State-File.

case $status in
    $MTC_EXIT_DAEMON_IS_NOT_PRESENT)
        # attempt to write directly to the host specific section
        writestatefile clearex $cf
        status=$?
        ;;
    *)
        ;;
esac

exit $status
