1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2014 OpenWrt.org
9 CONFIG_FILE
="/var/etc/rsyslog.conf"
10 BASE_CONFIG_FILE
="/etc/rsyslog.conf"
21 config_get src
${config} source
22 config_get dst
${config} destination
23 if [ ${src} != "" ] && [ "$dst" != "" ]; then
24 selectors
="${selectors}\n${src}\t${dst}\n"
37 config_get src
${config} source
38 config_get target
${config} target
39 config_get protocol
${config} protocol
"udp"
40 config_get port
${config} port
"514"
41 config_get rfc
${config} rfc
"3164"
43 if [ "$rfc" == "5424" ]; then
44 opts
='Template="RSYSLOG_SyslogProtocol23Format" TCP_Framing="octet-counted"'
47 if [ ${src} != "" ] && [ "${target}" != "" ]; then
48 action
="action(type=\"omfwd\" target=\"$target\" port=\"$port\" protocol=\"$protocol\" $opts action.resumeRetryCount=\"100\" queue.type=\"linkedList\" queue.size=\"10000\")"
49 forwarders
="${forwarders}\n${src}\t${action}\n"
58 config_load
${UCI_CONF}
59 config_list_foreach syslog modules handle_module
60 config_get_bool tcp_input syslog tcp_input
61 if [ ${tcp_input} -eq 1 ]; then
62 modules
="${modules} imtcp"
63 config_get tcp_port syslog tcp_input_port
64 input_t
="input(type=\"imtcp\" port=\"${tcp_port}\")"
67 config_get_bool udp_input syslog udp_input
68 if [ ${udp_input} -eq 1 ]; then
69 modules
="${modules} imudp"
70 config_get udp_port syslog udp_input_port
71 input_u
="input(type=\"imudp\" port=\"${udp_port}\")"
74 config_get template syslog default_template
75 config_foreach handle_selector selector
76 config_foreach handle_forwarder forwarder
78 mkdir
-p $
(dirname ${CONFIG_FILE})
80 echo "include(file=\"${BASE_CONFIG_FILE}\" mode=\"optional\")" >> ${CONFIG_FILE}
81 for m
in ${modules}; do
82 echo "module(load=\"${m}\")" >> ${CONFIG_FILE}
84 echo ${input_t} >> ${CONFIG_FILE}
85 echo ${input_u} >> ${CONFIG_FILE}
86 echo "\$ActionFileDefaultTemplate ${template}" >> ${CONFIG_FILE}
87 echo -e ${selectors} >> ${CONFIG_FILE}
88 echo -e ${forwarders} >> ${CONFIG_FILE}
93 modules
="${modules} $module"
99 procd_set_param
command /usr
/sbin
/rsyslogd
-f ${CONFIG_FILE} -n
106 procd_add_reload_trigger
${UCI_CONF}