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