{%- if grains['role'] == 'so-master' or grains['role'] == 'so-eval' %} {%- set ip = salt['pillar.get']('static:masterip', '') %} {%- elif grains['role'] == 'so-node' %} {%- set ip = salt['pillar.get']('node:mainip', '') %} {%- elif grains['role'] == 'so-sensor' %} {%- set ip = salt['pillar.get']('sensor:mainip', '') %} {%- endif %} #!/bin/bash ### # Shell script for registering agents automatically with the API # Copyright (C) 2017 Wazuh, Inc. All rights reserved. # Wazuh.com # # This program is a free software; you can redistribute it # and/or modify it under the terms of the GNU General Public # License (version 2) as published by the FSF - Free Software # Foundation. ### # # 12/11/2018 # This script has been modified by Security Onion Solutions # - Added Agent IP variable and option ### # Connection variables API_IP="localhost" API_PORT="55000" PROTOCOL="https" USER="foo" PASSWORD="bar" AGENT_NAME=$(hostname) AGENT_IP="{{ip}}" AGENT_ID=001 display_help() { cat < agent is not registered # if ! [ "$AGENT_ID" -eq "$AGENT_ID" ] 2> /dev/null ; then # echo "Starting registration process ..." # : # elif [[ "$FORCE" = true && "$SILENT" = "true" ]] ; then # remove_agent > /dev/null 2>&1 # else # if [[ "$FORCE" = true ]] ; then # remove_agent # fi # fi # Default action -> try to register the agent sleep 10s STATUS=$(curl -s -k -u $USER:$PASSWORD $PROTOCOL://$API_IP:$API_PORT/agents/$AGENT_ID | jq .data.status | sed s'/"//g') if [[ $STATUS == "Active" ]]; then echo "Agent $AGENT_ID already registered!" else register_agent fi #remove_agent