#!/usr/bin/env bash

# tune syslog-ng

cp /etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf.rpmsave

grep stats_freq /etc/syslog-ng/syslog-ng.conf || sed -i /etc/syslog-ng/syslog-ng.conf -e "s/keep_hostname (yes);/keep_hostname (yes);\n    stats_freq(43200);/"

#sed -i /etc/syslog-ng/syslog-ng.conf  -e 's|^\@include.*conf"$|#@include "/etc/syslog-ng/conf.d/*.conf"|' 

sed -i '/^@include .*conf.d\//d' /etc/syslog-ng/syslog-ng.conf

cat >>/etc/syslog-ng/syslog-ng.conf <<-EOF

source s_ext {
        tcp();
        udp();
};
EOF
systemctl enable  syslog-ng
systemctl restart syslog-ng

# limit journald

#sed -i.orig -e 's/^#Storage=.*$/Storage=volatile/' -e 's/^#ForwardToSyslog=.*$/ForwardToSyslog=yes/' -e 's/^#SystemMaxUse=.*$/SystemMaxUse=56M/' /etc/systemd/journald.conf
#systemctl restart systemd-journald.service
