#!/bin/bash

# prefcisd
#
# $Id: prefcisd 1757 2013-03-15 18:00:33Z jhealy $
#
# This is a FirstClass hook script.  It must reside in a folder that
# the FC init scripts (/etc/init.d/fc[i]sd) are configured to look for
# (/home/fcadmin/Documents by default, but Suffield Academy overrides this
# in the scripts to /opt/fcsd/suffield_prepost).
#
# This is a hook script that ties into commands issued by the
# FC InetSvcs controller, located at /usr/sbin/fcisctl.
# Please see that file for an idea of the types of commands that
# can be processed.
#
# Commands run in this script are run just BEFORE fcisctl starts
# the InetSvcs daemon on the machine.  Any arguments provided to
# fcisctl are passed directly to this script as well, one argument
# per invocation.  For example:
#
# /usr/sbin/fcisctl start status
#
# Would call this script with an arg of "start", then start the
# fcis service.  Next, it would call this script with an arg of
# "status", and then process the status argument itself.
#
# Finally, this script has access to any variable defined in the calling
# script.  Examples include:
#
#    SERVICE_NAME
#    SERVICE_APP
#    SERVICE_FOLDER
#    SERVICE_PID
#    USERDOCS
#

ARG="${1}"

echo "prefcisd: Executing preflight script with arg '${ARG}':"

case $ARG in
    start)
        # parent confirms that PID does not exist before calling preflight
	source "${USERDOCS}/fclogrotate"
	;;
    stop)
        # parent confirms that PID exists before calling preflight
	echo "prefcisd: No preflight operations for action '${ARG}'; skipping"
	;;
    restart)
        # parent confirms that PID exists before calling preflight
        # after this invocation, parent calls $0 start, so
        # you do not need to duplicate "start" options here
	echo "prefcisd: No preflight operations for action '${ARG}'; skipping"
	;;
    *)
	echo "prefcisd: Unknown argument '${ARG}'; skipping"
	;;
    
esac

