aboutsummaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorGiacomo Sanchietti <giacomo.sanchietti@nethesis.it>2022-06-20 16:54:45 +0200
committerRosen Penev <rosenp@gmail.com>2022-07-07 10:34:58 -0700
commitc3f6591de7002fd8d20564fd834e887ad9c3d416 (patch)
treeece9d893f8d3ea0a3b8bae3b7c936c34fa40d652 /admin
parenta3cea3655f3f61f0df657b9e6bb8ff0d07873d2c (diff)
rsyslog: apply shellcheck suggestions to init
Signed-off-by: Giacomo Sanchietti <giacomo.sanchietti@nethesis.it>
Diffstat (limited to 'admin')
-rw-r--r--admin/rsyslog/files/rsyslog.init42
1 files changed, 25 insertions, 17 deletions
diff --git a/admin/rsyslog/files/rsyslog.init b/admin/rsyslog/files/rsyslog.init
index a4e31b1fd..8ad2c86a6 100644
--- a/admin/rsyslog/files/rsyslog.init
+++ b/admin/rsyslog/files/rsyslog.init
@@ -1,6 +1,13 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 OpenWrt.org
+# shellcheck disable=SC3043
+# shellcheck disable=SC2034
+# shellcheck disable=SC3037
+# shellcheck disable=SC2154
+# shellcheck disable=SC3014
+# shellcheck disable=SC2129
+
START=20
USE_PROCD=1
@@ -18,9 +25,9 @@ handle_selector() {
local src
local dst
- config_get src ${config} source
- config_get dst ${config} destination
- if [ ${src} != "" ] && [ "$dst" != "" ]; then
+ config_get src "${config}" source
+ config_get dst "${config}" destination
+ if [ "${src}" != "" ] && [ "$dst" != "" ]; then
selectors="${selectors}\n${src}\t${dst}\n"
fi
}
@@ -34,17 +41,17 @@ handle_forwarder() {
local rfc
local opts
- config_get src ${config} source
- config_get target ${config} target
- config_get protocol ${config} protocol "udp"
- config_get port ${config} port "514"
- config_get rfc ${config} rfc "3164"
+ config_get src "${config}" source
+ config_get target "${config}" target
+ config_get protocol "${config}" protocol "udp"
+ config_get port "${config}" port "514"
+ config_get rfc "${config}" rfc "3164"
if [ "$rfc" == "5424" ]; then
opts='Template="RSYSLOG_SyslogProtocol23Format" TCP_Framing="octet-counted"'
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\")"
forwarders="${forwarders}\n${src}\t${action}\n"
fi
@@ -55,17 +62,17 @@ expand_config() {
local input_t=""
local input_u=""
- config_load ${UCI_CONF}
+ config_load "${UCI_CONF}"
config_list_foreach syslog modules handle_module
config_get_bool tcp_input syslog tcp_input
- if [ ${tcp_input} -eq 1 ]; then
+ if [ "${tcp_input}" -eq 1 ]; then
modules="${modules} imtcp"
config_get tcp_port syslog tcp_input_port
input_t="input(type=\"imtcp\" port=\"${tcp_port}\")"
fi
config_get_bool udp_input syslog udp_input
- if [ ${udp_input} -eq 1 ]; then
+ if [ "${udp_input}" -eq 1 ]; then
modules="${modules} imudp"
config_get udp_port syslog udp_input_port
input_u="input(type=\"imudp\" port=\"${udp_port}\")"
@@ -75,17 +82,18 @@ expand_config() {
config_foreach handle_selector selector
config_foreach handle_forwarder forwarder
- mkdir -p $(dirname ${CONFIG_FILE})
+ mkdir -p "$(dirname ${CONFIG_FILE})"
+ # shellcheck disable=SC2188
> ${CONFIG_FILE}
echo "include(file=\"${BASE_CONFIG_FILE}\" mode=\"optional\")" >> ${CONFIG_FILE}
for m in ${modules}; do
echo "module(load=\"${m}\")" >> ${CONFIG_FILE}
done
- echo ${input_t} >> ${CONFIG_FILE}
- echo ${input_u} >> ${CONFIG_FILE}
+ echo "${input_t}" >> ${CONFIG_FILE}
+ echo "${input_u}" >> ${CONFIG_FILE}
echo "\$ActionFileDefaultTemplate ${template}" >> ${CONFIG_FILE}
- echo -e ${selectors} >> ${CONFIG_FILE}
- echo -e ${forwarders} >> ${CONFIG_FILE}
+ echo -e "${selectors}" >> ${CONFIG_FILE}
+ echo -e "${forwarders}" >> ${CONFIG_FILE}
}
handle_module() {