#!/bin/sh
#
# ###################################################################
# Copyright (c) 2005-2014, EMC Corporation. All Rights Reserved.
#
# /etc/init.d/PowerMig
# This file is a part of EMC PowerPath.
#
# chkconfig: 35 99 99
# description: Runs PowerPath Migration Enabler recovery, if \
#              required on bootup.
#
# ###################################################################
#
### BEGIN INIT INFO
# Provides:          PowerMig
# Required-Start:
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Description:       PowerMig -- Runs PowerPath Migration Enabler recovery, \
#                    if required on bootup.
### END INIT INFO


PATH=/usr/bin/:/bin:/sbin:/usr/sbin

case "$1" in
    start)
        if [ -f /etc/redhat-release ]; then
            cat /etc/redhat-release | grep -v "^#" | \
                    grep "Red Hat"  > /dev/null
            if [ $? -eq 0 ]; then
                touch /var/lock/subsys/PowerMig
            fi
        fi

        /sbin/powermig recover -all -no > /dev/null 2>&1
        /sbin/powermig info -all -query > /dev/null 2>&1
        /sbin/powermig options -startupInProgress 0 > /dev/null 2>&1
        ;;

    stop)
        # The existence of /etc/emc/ppme ensures that PP has been
        # started, otherwise the umd open will fail (opt 400490).
        if [ -d /etc/emc/ppme ]; then 
            /sbin/powermig transition -no > /dev/null 2>&1
        fi
        ;;
    *)
        ;;
esac

