#!/bin/sh
# @description stop the agent
# @man Stop the agent service using the appropriate service manager.
# @man +
# @man *Options*:
# @man +
# @man *-k*: keep cf-serverd
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output

. "${BASEDIR}/../lib/common.sh"

QUIET=false

while getopts "qck" opt; do
  case $opt in
    q)
      QUIET=true
      ;;
    c)
      clear_colors
      ;;
    k)
      KEEP_SERVERD=y
      ;;
  esac
done

if [ "${KEEP_SERVERD}" = "y" ]
then
  service_action "rudder-cf-execd" "stop"
else
  service_action "rudder-agent" "stop"
fi
