refactoring changes from sequpgrade (endReturn, ...) and some modernizations
This commit is contained in:
@@ -5,16 +5,13 @@
|
||||
# source:
|
||||
# - https://selivan.github.io/2017/02/07/rsyslog-log-forward-save-filename-handle-multi-line-failover.html
|
||||
|
||||
toolName="rsyslog"
|
||||
toolConfig="/etc/rsyslog.conf"
|
||||
readonly toolName="rsyslog"
|
||||
readonly toolConfig="/etc/rsyslog.conf"
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
||||
CONFIG_SNMP="$WDIR/${toolName}/10-snmp.conf"
|
||||
CONFIG_CRON="$WDIR/${toolName}/10-cron.conf"
|
||||
CONFIG_RNGD="$WDIR/${toolName}/10-rngd.conf"
|
||||
CONFIG_REMOTE="$WDIR/${toolName}/90-remote.conf"
|
||||
CONFIG_SNMP="${seq_origin}/${toolName}/10-snmp.conf"
|
||||
CONFIG_CRON="${seq_origin}/${toolName}/10-cron.conf"
|
||||
CONFIG_RNGD="${seq_origin}/${toolName}/10-rngd.conf"
|
||||
CONFIG_REMOTE="${seq_origin}/${toolName}/90-remote.conf"
|
||||
|
||||
step_1_info() { echo "Install $toolName"; }
|
||||
step_1_alias() { echo "install"; }
|
||||
@@ -27,14 +24,14 @@ step_2_info() { echo "Check configuration"; }
|
||||
step_2_alias() { echo "checkconf"; }
|
||||
step_2() {
|
||||
exe rsyslogd -N 1 -f "$toolConfig"
|
||||
endReturn -o $? "Invalid $toolName configuration"
|
||||
endReturn "Invalid $toolName configuration"
|
||||
}
|
||||
|
||||
step_10_info() { echo "Reduce snmpd syslog messages"; }
|
||||
step_10_alias() { echo "snmpd"; }
|
||||
step_10() {
|
||||
addConf -s -f "$CONFIG_SNMP" "$CONFIG_SNMP_DEST"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -45,7 +42,7 @@ step_12_info() { echo "Reduce cron syslog messages"; }
|
||||
step_12_alias() { echo "cron"; }
|
||||
step_12() {
|
||||
addConf -s -f "$CONFIG_CRON" "$CONFIG_CRON_DEST"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -56,7 +53,7 @@ step_14_info() { echo "Reduce rngd syslog messages"; }
|
||||
step_14_alias() { echo "rngd"; }
|
||||
step_14() {
|
||||
addConf -s -f "$CONFIG_RNGD" "$CONFIG_RNGD_DEST"
|
||||
endReturn -o $?
|
||||
endReturn
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -69,17 +66,17 @@ step_16_alias() { echo "remote"; }
|
||||
step_16() {
|
||||
local rex='^[0-9\.]+\:[0-9]+$'
|
||||
local remoteHost=""
|
||||
# Check if string is a ipv4 address and port
|
||||
# Check if string is a ipv4 address and port
|
||||
if [[ "$2" =~ $rex ]] ; then
|
||||
remoteHost=$2
|
||||
else
|
||||
error -e "No valid IP:PORT detected: $2"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
addConf -s -f "$CONFIG_REMOTE" "$CONFIG_REMOTE_DEST"
|
||||
endReturn -o $? "Custom remote host $remoteHost not applied to destination or check ${sqr_missingConf:-}"
|
||||
endReturn "Custom remote host $remoteHost not applied to destination or check ${sqr_missingConf:-}"
|
||||
exe sed -i "s/12\.34\.56\.78\:514/${remoteHost}/" "$CONFIG_REMOTE_DEST"
|
||||
endReturn -o $? "Couldn't apply $remoteHost to $CONFIG_REMOTE_DEST"
|
||||
endReturn "Couldn't apply $remoteHost to $CONFIG_REMOTE_DEST"
|
||||
|
||||
step checkconf
|
||||
exe service rsyslog restart
|
||||
@@ -104,5 +101,7 @@ step_30() {
|
||||
SERVER_EOF
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
Reference in New Issue
Block a user