#!/bin/bash
# @description get connection logs on cf-serverd for a specific node
# @man The *-i* mode that spawned a separate server instance has been removed.
# @man +
# @man *Arguments*:
# @man +
# @man *-l*: fetch debug logs for the given node
# @man +
# @man *node*: IP or hostname of the host you want to debug

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

set -e

while getopts "i:l:" opt; do
  case $opt in
    i)
      "The iptables mode is not supported anymore"
      exit 1
      ;;
    l)
      NODE="${OPTARG}"
      ;;
  esac
done

if is_https_only; then
  echo "HTTPS only mode is enabled. This command only handles the CFEngine protocol."
  exit 1
fi

if [ -z "${NODE}" ]
then
  echo "Usage rudder server debug [-l] <node_ip>"
  exit 1
fi

journalctl -f -xe -u rudder-cf-serverd | grep "${NODE}"
