#!/usr/bin/bash

apt update && apt install -y rsyslog
systemctl enable rsyslog

myhostname=$(hostname --fqdn)
echo $myhostname
cat > /etc/rsyslog.d/its.conf << EOF
\$template ITStemplate, "<%pri%> %timestamp% ${myhostname} %syslogtag% %msg%\n"
\$ActionForwardDefaultTemplate ITStemplate
EOF

grep -qF '*.* @rsync.alexunderboots.ru:514' "/etc/rsyslog.conf" || ( \
	yes | cp -i /etc/rsyslog.conf /root/rsyslog.conf.0 && \
	echo '*.* @rsync.alexunderboots.ru:514' >> /etc/rsyslog.conf && \
	systemctl restart rsyslog )

