cluster-deployment/src/steps-config/100-logging.sh

43 lines
876 B
Bash
Executable File

#!/usr/bin/env bash
logging_mode="$(ask_multichoice "Logging mode" "rsyslog-client" "ramlog" "none")";
do_ramlog() {
if ! grep -q '# ---SBRL-RAMLOG---' /etc/fstab; then
echo "# ---SBRL-RAMLOG---" >>/etc/fstab;
echo "tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid,noexec,mode=1777" >>/etc/fstab;
fi
echo "#!/usr/bin/env bash
rm -rf /var/log/*
" >/etc/cron.hourly/clear-logs
chmod +x /etc/cron.hourly/clear-logs;
}
case "${logging_mode}" in
rsyslog-client )
queue_apt_install "rsyslog" "rsyslog-gnutls";
do_ramlog
;;
ramlog )
do_ramlog
;;
none )
if ! command_exists logrotate; then
task_begin "Installing logrotate";
queue_apt_install logrotate;
mkdir -p /etc/logrotate.d;
touch /etc/logrotate.d/misc;
task_end "$?" "Failed to configure installation of logrotate";
fi
;;
esac
# TODO: Finish this off.