#!/bin/sh
# @file
#
# @brief Script to start/stop system information daemon (sxsivm)
#
# Copyright 2014 Red Lion Controls, Inc.
# All Rights reserved.
#
#
log="/dev/null"
#log="/var/log/`basename $0`"

#
# This only stops the sixnet applications that are not
# started by init.
#
stop()
{
    echo "Stopping Sixnet Applications" >> $log
    #
    # Kill the sysinfod application.
    #
    monit stop sxsivm
}

#
# Load the iodb/stbus driver and start all the Sixnet applications
# that are not started by init.
#
start()
{
    echo "Starting the system information daemon - sxsivm" >> $log
    #
    # Start the Sixnet IPm applications
    #
    monit start sxsivm
    sh /usr/local/bin/audit_trail.sh
}

#
# This only restarts the sixnet applications that
# are not started by init.
#
restart()
{
    stop
    start
}

#
# Check to see if a command was passed into the script.
#
if [ "$1" ]; then
    case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        restart)
            restart
            ;;
        *)
            echo "Usage: sysinfod [ start | stop | restart ]"
            exit 1
            ;;
    esac
    exit
fi

# No command passed in, assume start
start
