#! /bin/sh
#
# Copyright (c) 2013-2016 Nagios Enterprises, LLC
# All rights reserved.
#

# NagiosNA daemon that spins up nfcapd instances
pythonbin=$(which python 2>/dev/null || which python2 2>/dev/null)
controller=/usr/local/nagiosna/scripts/source_controller.py

case "$1" in
    start)
        if [ -n "$2" ]; then
          $pythonbin "$controller" start "$2"
        else
          $pythonbin "$controller" start
        fi
        ;;
    stop)
        shift
        # Pass through flags (e.g. --deactivate) and optional source name.
        $pythonbin "$controller" stop "$@"
        ;;
# status only works with a single capd service, not apporiate for a init script
#  will fix status to do a status all... then reenable it.
#    status)
#        python /usr/local/nagiosna/scripts/source_controller.py status
#        ;;
    *)
        ## If no parameters are given, print which are avaiable.
#        echo "Usage: $0 {start|stop|status|restart}
        echo "Usage: $0 {start|stop|restart}"
        echo "       $0 stop --deactivate <source_name>"
        exit 1
        ;;
esac
