File: rsyslog_log_utils.sh

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (32 lines) | stat: -rwxr-xr-x 866 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

RSYSLOG_CONF='/etc/rsyslog.conf'
RSYSLOG_CONF_DIR='/etc/rsyslog.d'
LOG_FILE_PREFIX=test
RSYSLOG_TEST_DIR=/tmp
declare -a RSYSLOG_TEST_LOGS

# This function creates test rsyslog log files
# Parameters: $1 - number of log files to be created
function create_rsyslog_test_logs {
        local count=$1

        RSYSLOG_TEST_DIR=$(mktemp -d)
        RSYSLOG_TEST_LOGS=()

        if [ $? -ne 0 ]; then
            echo "Failed to create RSYSLOG_TEST_DIR"
            exit 1
        fi

        if ! [[ "$count" =~ ^[0-9]+$ ]] || [ $count -eq 0 ]; then
            echo "Argument 'count' is not a positive number: $count"
            exit 1
        fi

        for ind in $(seq 1 $count); do
            local testlog=${RSYSLOG_TEST_DIR}/${LOG_FILE_PREFIX}${ind}.log
            touch ${testlog}
            RSYSLOG_TEST_LOGS+=("${testlog}")
        done;
}