#  Service.run:  1.01 10/07/2004 RM Copyright (c) 2004-2019, Hitachi, Ltd.
#
#  NAME   : A sample for starting HORCM #0 from a service.
#  This file is an example for running the service process for HORCM #0,
#
#  [NOTE]:
#  - This file should be protected by specifiying the permissions.

INTERROGATE: 30 
 C:\HORCM\etc\raidqry.exe -l 
 if !0
 then
   call RESTART: 
 fi
 exit

#  ****  For INSTANCE# X, change to HORCMINST=X as needed  ****
START:
 set HORCMINST=0
 set HORCC_LOG=STDERROUT
 C:\HORCM\etc\horcmstart.exe 
 exit 0
#  **** Change to 'exit' if you want to detect ERROR at starting or BOOT. ****


STOP:
 C:\HORCM\etc\raidqry.exe -l 
 if 0
   C:\HORCM\etc\horcmshutdown.exe
 else
   echo "Detected Shutdown  !!!"
   exit 0
 fi
 exit


RESTART:
 echo "Detected Shutdown  !!!"
 C:\HORCM\etc\horcmstart.exe 
 if 0
   echo "Restarted from failure  !!!"
 else
   echo "We will stop INTERROGATE because of failure for re-starting !!!"
 fi
 exit 


HINTERROGATE: 
 echo "Called interrogate as EVENT  !!!"
 exit  0



# [1] DESCRIPTION:
#
# This file will be executed via SVCEXE.EXE registered as the service process, and
# should be named as below.
# If the path name registerd to the service is 'C:\DIR...\svcexe.exe' and the name
# is 'HORCMSTART',then this file need to be named as 'C:\DIR...\HORCMSTART_run.txt'.
#
# SVCEXE.EXE executes the label entry which was written in this file as the service
# event, and the results are logged as 'C:\DIR...\HORCMSTART_log.txt'.
# The following entrys which was defined as the service event will be called from a 
# main thread for the service.
# 
# START:
# This will be called at starting service (i.e. when you pushued the start button,
# or started on BOOT automatically).
# If this routine exited with '0', then the service become the RUNNING state.
# If not, the service become the STOP state, in addition to this, if it happened
# on BOOT, then puts up a message box pop-up. 
#
# INTERROGATE:
# This will be called on RUNNING state at regular interval for confirming whether
# the process is running or not. the default interval time is 10 seconds.
# In other word, this routine will be suspended in PAUSE state.
# If you want to change to 30 seconds, you are able to specify as below.
# INTERROGATE: 30 
# If this routine exited with '0', then the service will be continued at RUNNING state.
# If not, the service become the STOP state. 
# 
# These following entrys will be called from a control handler for the service.
# (i.e. when you pushued the stop/pause/continue/button)
#
# STOP:
# If this routine exited with '0', then the service become the STOP state.
# If not, the state will not be changed. (This will be called from 'net stop').
# PAUSE:
# If this routine exited with '0', then the service become the PAUSE state.
# If not, the state will not be changed.
# CONTINUE:
# If this routine exited with '0', then the service become the RUNNING state.
# If not, the state will not be changed.
# HINTERROGATE:
# If this routine exited with '0', then the service will be continued at RUNNING state.
# If not, the service become the STOP state. (This will be called from 'net start').
#
# XXXXX:
# In addition to this, it is possible to define any label entry except the above
#  optionally, and also each label can use the following syntax.
#
# [2] SYNTAX:
#
# Execution statements are :
# - set <valiable>=<value> ... sets an environment variable
# - set <valiable>=        ... unsets an environment variable 
# - sleep [value]          ... sleeps at value in unit of second
# - echo <"strings">       ... outputs "strings" into above log file.
# - call <label:>          ... executes the statements under a label:
# - any executable command ... executes a statement as a command, and sets the result
#                              to status.
# Control statements are :
# - if <value>   ... If (status == value) 
# - if <!value>  ... If (status != value)
# - then         ... interprets the following statements as 'then'(this is omittable)
# - else         ... interprets the following statements as 'else' 
# - elif <value> ... interprets the following statements as 'else' and 'if (status == value)'
# - elif <!value>... interprets the following statements as 'else' and 'if (status != value)'
# - fi           ... terminate 'if' statement
# - exit [value] ... exits and return a status from a entry if value is not specified. 
#
# [3] ENVIRONMENT VARIABLES :
#
# About changing the Log directory for HORCM
# You are able to change the default Log directory by setting the environment variables
# for HORCM.
# For example:
# - set HORCMINST=X                        [where X is an instance number]
# - set HORCM_LOG=Drive:\DIR\logX\curlog   [where Drive is the specified drive such as C:]
# - set HORCM_LOGS=Drive:\DIR\logX\tmplog  [where DIR is the specified directory]
# - horcmstart                             [must be specified without an argument]
#
# Also you are able to specify the following the environment variables as needed.
# HORCM_CONF=Drive:\DIR\....
#
# HORCMPERM=MGRNOINST
#
# HORCM_EVERYCLI=1  
# This will be needed if you start this service with Local system account.
# 
# HORCM_EXECWAIT
# This makes it possible to re-start directly as below example.
#
# For example:
#
# INTERROGATE: 1 
# C:\HORCM\etc\raidqry.exe -l 
# if !0
# then
#   echo "HORCM STARTED !!!" 
#   C:\HORCM\etc\horcmstart.exe 
#   if 0
#   then
#     echo "HORCM terminated successfully." 
#   elif 1
#     echo "HORCM already running happened."
#   else
#     echo "HORCM terminated abnormally." 
#   fi
# else
##   echo "We will only wait, because someone started up HORCM."
#   sleep 10
# fi
# exit 0
#
# START:
#  set HORCMINST=0
#  set HORCM_EXECWAIT=1 
#  set HORCC_LOG=STDERROUT
#  sleep 3
#  exit 0
# 
# [4] ENVIRONMENT VARIABLES for RM commands:
#
# About changing the Log directory for RM commands 
# HORCC_LOG=Drive:\DIR\....
# HORCC_LOG=STDERROUT
#
# [5] CHANGELOG:
# Revision 1.00   10/07/2004   k.urabe Initial revision


##########################################################################################
# For speed up interpreting, please execute without unnecessary comments.
##########################################################################################

