#!/bin/bash

. /etc/appliance/scriptsLib-3.0/maintenance.lib

# checks for maintenance_state for previous attempts
state=`getMaintenanceState`
if [ $? != 0 ]; then
    log_messages 1 "PRE_MAINTENANCE" "Could not get maintenance state"
    exit 1
fi

if [ $state != "$STATE_PRE_MAINTENANCE" ]; then
    # nothing to be done here
    exit 0
fi

# XXXX check the only script running is this one (will do it later)

#
# We used to disable the active domains here but we don't want to do
# that anymore - we want to keep them running during the upgrade.
#

# set maintenance_state
setMaintenanceState $STATE_MAINTENANCE
if [ $? != 0 ]; then
    log_messages 1 "PRE_MAINTENANCE" "Could not enter maintenace"
    exit 1
fi


