File: rsyslogd-start.sh

package info (click to toggle)
dracut 110-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,184 kB
  • sloc: sh: 24,970; ansic: 5,236; makefile: 346; perl: 186; python: 48; javascript: 19
file content (47 lines) | stat: -rwxr-xr-x 1,265 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

# Triggered by initqueue/online and starts rsyslogd with bootparameters

command -v getarg > /dev/null || . /lib/dracut-lib.sh

# prevent starting again if already running
if [ -f /var/run/syslogd.pid ]; then
    read -r pid < /var/run/syslogd.pid
    kill -0 "$pid" && return 0
fi

rsyslog_config() {
    local server="$1"
    shift
    local syslog_template="$1"
    shift
    local filters="$*"
    local filter=

    cat "$syslog_template"

    (
        # disable shell expansion / globbing
        # since filters contain such characters
        set -f
        for filter in $filters; do
            echo "${filter} @${server}"
        done
    )
    #echo "*.* /tmp/syslog"
}

[ -f /tmp/syslog.type ] && read -r type < /tmp/syslog.type
[ -f /tmp/syslog.server ] && read -r server < /tmp/syslog.server
[ -f /tmp/syslog.filters ] && read -r filters < /tmp/syslog.filters
[ -z "$filters" ] && filters="kern.*"
[ -f /tmp/syslog.conf ] && read -r conf < /tmp/syslog.conf
[ -z "$conf" ] && conf="/etc/rsyslog.conf" && echo "$conf" > /tmp/syslog.conf

if [ "$type" = "rsyslogd" ]; then
    template=/etc/templates/rsyslog.conf
    if [ -n "$server" ]; then
        rsyslog_config "$server" "$template" "$filters" > "$conf"
        rsyslogd -c3
    fi
fi