{% set mainint = salt['pillar.get']('host:mainint') -%} {% set ip = salt['grains.get']('ip_interfaces').get(mainint)[0] -%} #!/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="{{ ip }}" 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 if [ -f /opt/so/conf/wazuh/initial_agent_registration.log ]; then echo "Agent $AGENT_ID already registered!" exit 0 else retries=20 if wait_for_manager $retries; then if register_agent; then cleanup_creds echo "Initial agent $AGENT_ID with IP $AGENT_IP registered on $DATE." > /opt/so/conf/wazuh/initial_agent_registration.log exit 0 else echo "ERROR: Failed to register agent" fi else echo "ERROR: Wazuh manager did not become ready after $retries attempts; unable to proceed with registration" fi fi exit 1