#!/bin/sh
# @description start the relay service
# @man Start the relay service using the appropriate service manager.
# @man +
# @man *Options*:
# @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 "qc" opt; do
  case $opt in
    q)
      QUIET=true
      ;;
    c)
      clear_colors
      ;;
  esac
done

if [ -s ${RUDDER_VAR}/lib/ssl/allnodescerts.pem ]; then chgrp rudder ${RUDDER_VAR}/lib/ssl/allnodescerts.pem; fi
if [ -f ${RUDDER_VAR}/lib/relay/nodeslist.json ]; then chown rudder-relayd ${RUDDER_VAR}/lib/relay/nodeslist.json; fi
service_action "rudder-relayd" "start"
