From f2b677bfcb1045d6b629c6bcc3b703eb1d14aa4e Mon Sep 17 00:00:00 2001 From: Wes Lambert Date: Wed, 6 Jan 2021 15:52:10 +0000 Subject: [PATCH] Reserve port for Wazuh API and check if port is already in use --- salt/wazuh/init.sls | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/salt/wazuh/init.sls b/salt/wazuh/init.sls index 99f16cb8a..3cad6c367 100644 --- a/salt/wazuh/init.sls +++ b/salt/wazuh/init.sls @@ -96,6 +96,16 @@ wazuhmgrwhitelist: - mode: 755 - template: jinja +# Reserve OS port for Wazuh API +wazuhreserveport: + cmd.run: + - name: grep -q 55000 /proc/sys/net/ipv4/ip_local_reserved_ports || sysctl -w net.ipv4.ip_local_reserved_ports="55000" > /dev/null && echo "55000" >> /proc/sys/net/ipv4/ip_local_reserved_ports + +# Check to see if Wazuh API port is available +wazuhportavailable: + cmd.run: + - name: netstat -anp | grep 55000 | grep -qv docker && PROCESS=$(netstat -anp | grep 55000 | awk '{print $NF}' | uniq) && echo "Another process ($PROCESS) appears to be using port 55000. Please terminate this process, or reboot to ensure a clean state so that the Wazuh API can start properly." && exit 1 || exit 0 + so-wazuh: docker_container.running: - image: {{ MANAGER }}:5000/{{ IMAGEREPO }}/so-wazuh:{{ VERSION }} @@ -158,4 +168,4 @@ wazuh_state_not_allowed: test.fail_without_changes: - name: wazuh_state_not_allowed -{% endif %} \ No newline at end of file +{% endif %}