#! /bin/bash
cyflexlogevent -t generic -m 1 -m "script" -m "$0" 

# This script stops the external data manager for loading files from an
# external site to Cummins.
#
# It finds the process ID for the MSU data loading.
# If a process is not located this terminates.
# The "stop file" for this processing data loading is determined from
# the configuration file.
# stop_loading is invoked with suitable arguments.
#
# Usage: /cyflex/cmds/stop_cummins_data_loading
#
# Author: Rob Janes
#
# History
#   08/09/11 - Rob Janes - Initial release.
#

PROG=com.cybermetrix.cyflex.extdatman.SendCumminsData
FILE=/specs/extdatman.cummins_data
# Find the PID for the cummins data loading process.
PID=$(ps -ef | grep $PROG | grep $FILE | grep -v grep | tr -s ' ' | cut -f2 -d\ )
# If cummins data loading isn't running, no need to stop it.
if [ "$PID" = "" ]; then
   exit 0
fi

# File the stop file name.
STOP_FILE=`grep cyflex.extdatman.stopFile $FILE | cut -f2 -d\  `

# Invoke the common stopping script.
stop_loading $PID $STOP_FILE 60 5
