diff options
author | Dominik Lisiak <dominik.lisiak@bemsoft.pl> | 2018-10-13 20:51:51 +0200 |
---|---|---|
committer | Dominik Lisiak <dominik.lisiak@bemsoft.pl> | 2018-10-13 20:51:51 +0200 |
commit | 495280d9dc4ff5efd555f50e65a120df1b780003 (patch) | |
tree | 803a4c755cb0664126be9ef065d4e8c923365b7e /security/ossec-hids-local-config/files/agent-conf.in | |
download | ossec-495280d9dc4ff5efd555f50e65a120df1b780003.tar.xz |
Initial commit for version 3.0.03.0.0
Diffstat (limited to 'security/ossec-hids-local-config/files/agent-conf.in')
-rw-r--r-- | security/ossec-hids-local-config/files/agent-conf.in | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/security/ossec-hids-local-config/files/agent-conf.in b/security/ossec-hids-local-config/files/agent-conf.in new file mode 100644 index 0000000..673d0f6 --- /dev/null +++ b/security/ossec-hids-local-config/files/agent-conf.in @@ -0,0 +1,33 @@ +#!/bin/sh + +ossec_type="%%OSSEC_TYPE%%" +ossec_home="%%OSSEC_HOME%%" + +agent_conf_dir="${ossec_home}/etc/agent.conf.d" +agent_conf_files="${agent_conf_dir}/*.conf" + +select_elements() { + local element="$1" + sed -n "/<${element}.*>/,/<\/${element}>/p" +} + +remove_comments() { + # Comments must be on separate lines i.e. not next to uncommented code + awk '/<!--/ {off=1} /-->/ {off=2} /([\s\S]*)/ {if (off==0) print; if (off==2) off=0}' +} + +remove_empty_lines() { + sed '/^\s*$/d' +} + +agent_conf() { + + echo "<!-- OSSEC HIDS %%VERSION%% -->" + echo + echo "<!-- DO NOT EDIT - file generated automatically - edit \"agent.conf.d/900.local.conf\" instead -->" + echo + + cat $@ | remove_comments | select_elements "agent_config" | remove_empty_lines +} + +agent_conf "${agent_conf_files}" |