rsyslog: replace spaces with tabs inside init
Signed-off-by: Giacomo Sanchietti <giacomo.sanchietti@nethesis.it>
This commit is contained in:
parent
7afd539dbf
commit
008860276e
1 changed files with 61 additions and 61 deletions
|
@ -21,84 +21,84 @@ selectors=""
|
||||||
forwarders=""
|
forwarders=""
|
||||||
|
|
||||||
handle_selector() {
|
handle_selector() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
local src
|
local src
|
||||||
local dst
|
local dst
|
||||||
|
|
||||||
config_get src "${config}" source
|
config_get src "${config}" source
|
||||||
config_get dst "${config}" destination
|
config_get dst "${config}" destination
|
||||||
if [ "${src}" != "" ] && [ "$dst" != "" ]; then
|
if [ "${src}" != "" ] && [ "$dst" != "" ]; then
|
||||||
selectors="${selectors}\n${src}\t${dst}\n"
|
selectors="${selectors}\n${src}\t${dst}\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_forwarder() {
|
handle_forwarder() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
local src
|
local src
|
||||||
local target
|
local target
|
||||||
local protocol
|
local protocol
|
||||||
local port
|
local port
|
||||||
local rfc
|
local rfc
|
||||||
local opts
|
local opts
|
||||||
|
|
||||||
config_get src "${config}" source
|
config_get src "${config}" source
|
||||||
config_get target "${config}" target
|
config_get target "${config}" target
|
||||||
config_get protocol "${config}" protocol "udp"
|
config_get protocol "${config}" protocol "udp"
|
||||||
config_get port "${config}" port "514"
|
config_get port "${config}" port "514"
|
||||||
config_get rfc "${config}" rfc "3164"
|
config_get rfc "${config}" rfc "3164"
|
||||||
|
|
||||||
if [ "$rfc" == "5424" ]; then
|
if [ "$rfc" == "5424" ]; then
|
||||||
opts='Template="RSYSLOG_SyslogProtocol23Format" TCP_Framing="octet-counted"'
|
opts='Template="RSYSLOG_SyslogProtocol23Format" TCP_Framing="octet-counted"'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${src}" != "" ] && [ "${target}" != "" ]; then
|
if [ "${src}" != "" ] && [ "${target}" != "" ]; then
|
||||||
action="action(type=\"omfwd\" target=\"$target\" port=\"$port\" protocol=\"$protocol\" $opts action.resumeRetryCount=\"100\" queue.type=\"linkedList\" queue.size=\"10000\")"
|
action="action(type=\"omfwd\" target=\"$target\" port=\"$port\" protocol=\"$protocol\" $opts action.resumeRetryCount=\"100\" queue.type=\"linkedList\" queue.size=\"10000\")"
|
||||||
forwarders="${forwarders}\n${src}\t${action}\n"
|
forwarders="${forwarders}\n${src}\t${action}\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
expand_config() {
|
expand_config() {
|
||||||
local input_t=""
|
local input_t=""
|
||||||
local input_u=""
|
local input_u=""
|
||||||
|
|
||||||
config_load "${UCI_CONF}"
|
config_load "${UCI_CONF}"
|
||||||
config_list_foreach syslog modules handle_module
|
config_list_foreach syslog modules handle_module
|
||||||
config_get_bool tcp_input syslog tcp_input
|
config_get_bool tcp_input syslog tcp_input
|
||||||
if [ "${tcp_input}" -eq 1 ]; then
|
if [ "${tcp_input}" -eq 1 ]; then
|
||||||
modules="${modules} imtcp"
|
modules="${modules} imtcp"
|
||||||
config_get tcp_port syslog tcp_input_port
|
config_get tcp_port syslog tcp_input_port
|
||||||
input_t="input(type=\"imtcp\" port=\"${tcp_port}\")"
|
input_t="input(type=\"imtcp\" port=\"${tcp_port}\")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
config_get_bool udp_input syslog udp_input
|
config_get_bool udp_input syslog udp_input
|
||||||
if [ "${udp_input}" -eq 1 ]; then
|
if [ "${udp_input}" -eq 1 ]; then
|
||||||
modules="${modules} imudp"
|
modules="${modules} imudp"
|
||||||
config_get udp_port syslog udp_input_port
|
config_get udp_port syslog udp_input_port
|
||||||
input_u="input(type=\"imudp\" port=\"${udp_port}\")"
|
input_u="input(type=\"imudp\" port=\"${udp_port}\")"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
config_get template syslog default_template
|
config_get template syslog default_template
|
||||||
config_foreach handle_selector selector
|
config_foreach handle_selector selector
|
||||||
config_foreach handle_forwarder forwarder
|
config_foreach handle_forwarder forwarder
|
||||||
|
|
||||||
mkdir -p "$(dirname ${CONFIG_FILE})"
|
mkdir -p "$(dirname ${CONFIG_FILE})"
|
||||||
# shellcheck disable=SC2188
|
# shellcheck disable=SC2188
|
||||||
> ${CONFIG_FILE}
|
> ${CONFIG_FILE}
|
||||||
echo "include(file=\"${BASE_CONFIG_FILE}\" mode=\"optional\")" >> ${CONFIG_FILE}
|
echo "include(file=\"${BASE_CONFIG_FILE}\" mode=\"optional\")" >> ${CONFIG_FILE}
|
||||||
for m in ${modules}; do
|
for m in ${modules}; do
|
||||||
echo "module(load=\"${m}\")" >> ${CONFIG_FILE}
|
echo "module(load=\"${m}\")" >> ${CONFIG_FILE}
|
||||||
done
|
done
|
||||||
echo "${input_t}" >> ${CONFIG_FILE}
|
echo "${input_t}" >> ${CONFIG_FILE}
|
||||||
echo "${input_u}" >> ${CONFIG_FILE}
|
echo "${input_u}" >> ${CONFIG_FILE}
|
||||||
echo "\$ActionFileDefaultTemplate ${template}" >> ${CONFIG_FILE}
|
echo "\$ActionFileDefaultTemplate ${template}" >> ${CONFIG_FILE}
|
||||||
echo -e "${selectors}" >> ${CONFIG_FILE}
|
echo -e "${selectors}" >> ${CONFIG_FILE}
|
||||||
echo -e "${forwarders}" >> ${CONFIG_FILE}
|
echo -e "${forwarders}" >> ${CONFIG_FILE}
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_module() {
|
handle_module() {
|
||||||
local module="$1"
|
local module="$1"
|
||||||
modules="${modules} $module"
|
modules="${modules} $module"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
@ -111,5 +111,5 @@ start_service() {
|
||||||
|
|
||||||
service_triggers()
|
service_triggers()
|
||||||
{
|
{
|
||||||
procd_add_reload_trigger ${UCI_CONF}
|
procd_add_reload_trigger ${UCI_CONF}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue