#!/bin/bash
#
# Author: Vlad Ungureanu <vlad.ungureanu@siemens.com>
#
### BEGIN INIT INFO
# Provides: run_after_recovery
# Required-Start: $network sshd
# Required-Stop: $network sshd
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Restore the Assistant HBR and CSTA backups after recovery 
### END INIT INFO

#HOC
#ver 0.1
# - initial creation

RECOV_ACTIONS=/opt/recoveryISO/actions_after_recovery.sh
PID_FILE=/tmp/_pid_actions_after_recovery_

. /etc/rc.status

rc_reset
case "$1" in
  start)
    ( checkproc -p $PID_FILE /bin/bash ) && echo "daemon is already running"
    echo -n "Starting Actions before RecoveryISO daemon..."
    [ ! -x $RECOV_ACTIONS ] && chmod u+x $RECOV_ACTIONS
    startproc -f -p $PID_FILE /bin/bash $RECOV_ACTIONS
    rc_status -v
    ;;
  stop)
    echo -n "Stopping Actions before RecoveryISO daemon."
    killproc -p $PID_FILE -TERM -t20 /bin/bash
    rc_status -v
    ;;
  status)
    echo -n "Checking for service ActionsAfterRecoveryISO"
    checkproc -p $PID_FILE /bin/bash
    rc_status -v
    ;;
  *)
    echo "Usage: $0 (start|stop|status)"
    exit 6
    ;;
esac
rc_exit
