ports/security/ossec-hids-local-config/scripts/template-to-agent.sh
Steve Wills 868061ef79 security/ossec-hids-server: update from 2.8.3 to 3.1.0
PR:		232794
Submitted by:	Dominik Lisiak <dominik.lisiak@bemsoft.pl> (maintainer)
2018-11-09 18:52:21 +00:00

33 lines
813 B
Bash

#!/bin/sh
if [ $# -lt 3 ]; then
echo "Too few arguments"
echo "Usage: `basename $0` <ossec_type> <ossec_prefix> <ossec_file>"
exit 1
fi
ossec_type="$1"
ossec_prefix="$2"
ossec_file="$3"
if [ ! -f "${ossec_file}" ]; then
echo "File \"${ossec_file}\" does not exist"
exit 1
fi
ossec_syscheck_bin_dirs="${ossec_prefix}/bin,${ossec_prefix}/active-response"
ossec_syscheck_etc_dirs="${ossec_prefix}/etc"
replace() {
sed -e 's|<template_config \(.*\)>|<agent_config \1>|' \
-e 's|</template_config>|</agent_config>|' \
-e "s|%%OSSEC_SYSCHECK_BIN_DIRS%%|${ossec_syscheck_bin_dirs}|" \
-e "s|%%OSSEC_SYSCHECK_ETC_DIRS%%|${ossec_syscheck_etc_dirs}|" \
"${ossec_file}"
}
extract() {
sed -n '/^<agent_config .*>$/,/^<\/agent_config>$/p'
}
replace | extract