48 lines
1.1 KiB
Bash
48 lines
1.1 KiB
Bash
#!/bin/sh
|
|
|
|
# you need to specify this
|
|
TARGET_HOST=${TARGET_HOST:-127.0.0.1}
|
|
|
|
# tcp (default) | udp
|
|
TARGET_PROTO=${TARGET_PROTO:-tcp}
|
|
|
|
# 514 is the common default
|
|
TARGET_PORT=${TARGET_PORT:-514}
|
|
|
|
cat >/etc/rsyslog.conf <<EOF
|
|
\$WorkDirectory /var/lib/rsyslog
|
|
|
|
# Sets default permissions for all log files.
|
|
\$FileOwner root
|
|
\$FileGroup adm
|
|
\$FileCreateMode 0640
|
|
\$DirCreateMode 0755
|
|
\$Umask 0022
|
|
\$PreserveFQDN on
|
|
|
|
module(load="imudp")
|
|
input(type="imudp" port="514" )
|
|
|
|
module(load="imtcp")
|
|
input(type="imtcp" port="514" )
|
|
|
|
module(load="mmutf8fix")
|
|
action(type="mmutf8fix" replacementChar="?" )
|
|
|
|
# If the hostname is not specified, we use fromhost
|
|
if (\$hostname == '') then set \$!hostname = \$fromhost;
|
|
|
|
EOF
|
|
|
|
if [ "${TARGET_PROTO}" = "udp" ] ; then
|
|
cat >>/etc/rsyslog.conf <<EOF
|
|
action(type="omfwd" protocol="udp" target="${TARGET_HOST}" port="${TARGET_PORT}" Template="RSYSLOG_SyslogRFC5424Format" )
|
|
EOF
|
|
else
|
|
cat >>/etc/rsyslog.conf <<EOF
|
|
action(type="omfwd" protocol="tcp" target="${TARGET_HOST}" port="${TARGET_PORT}" Template="RSYSLOG_SyslogRFC5424Format" TCP_Framing="octet-counted" KeepAlive="on" )
|
|
EOF
|
|
fi
|
|
|
|
/usr/sbin/rsyslogd -nf /etc/rsyslog.conf
|