#!/bin/sh

#
# ALU ICT8000 Upgrade init script -- start
#
# chkconfig: 345 89 --
# description:  check if application manager process is runing. If not, cleanup upgrade files and reboot
#
# Changelog:
#	- Fri Sep 10 2010 - Guillaume Catto <guillaume.catto@alcatel-lucent.com>
#	* Fix crms00258989: script creation to solve this error
#       - The Aug 16 2012 - Jerry ZHOU <jerry.zhou@alcatel-lucent.com>
#       * Fix crms00390845: do upgrade directory clean only when upgrade status is not 'pre0'
#

# Source others scripts to get configuration and functions
source /usr/lib/upgrade/rpmdbbackup-addon.sh

start() {
    local FUNCTION=start
    ENTER_FUNCTION
#crms00390845 jerryzh+
    [[ -f "$statusfile" ]] && source $statusfile
#crms00390845 jerryzh-
    get_application_manager_status
#crms00390845 jerryzh+
    [[ $? == 0 ]] && [[ x$STEP != xpre0 ]] && cleanup 1
#crms00390845 jerryzh-
    RETURN
}

echo "entering $0 ..."

case "$1" in
	start)
		start
		RETVAL=$?
		;;
	*)
		echo "Usage: $0 start"
		RETVAL=1
		;;
esac

echo "leaving $0 ..."
exit $RETVAL

