tftpboot/preseed/finish/post.sh

53 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
RSYSLOGD_CONF="$(dirname $0)/rsyslog/rsyslog.conf"
RSYSLOGD_FILE="/etc/rsyslog.conf"
RSYSLOGD_SYSLOG_CONF="$(dirname $0)/rsyslog/syslogd.conf"
RSYSLOGD_SYSLOG_FILE="/etc/rsyslog.d/syslogd.conf"
LOGROTATE_CONF="$(dirname $0)/logrotate/logrotate.conf"
LOGROTATE_FILE="/etc/logrotate.conf"
LOGROTATE_SYSLOG_CONF="$(dirname $0)/logrotate/rsyslog"
LOGROTATE_SYSLOG_FILE="/etc/logrotate.d/rsyslog"
LOGROTATE_APTITUDE_CONF="$(dirname $0)/logrotate/aptitude"
LOGROTATE_APTITUDE_FILE="/etc/logrotate.d/aptitude"
LOGROTATE_DPKG_CONF="$(dirname $0)/logrotate/dpkg"
LOGROTATE_DPKG_FILE="/etc/logrotate.d/dpkg"
### Rsyslog ###
# Install new Rsyslog configuration
if [ -f "${RSYSLOGD_FILE}" ]; then
cp "${RSYSLOGD_CONF}" "${RSYSLOGD_FILE}"
fi
cp "${RSYSLOGD_SYSLOG_CONF}" "${RSYSLOGD_SYSLOG_FILE}"
# Remove old log files
## Kernel log files
rm -f /var/log/kern.log
## Authentication log files
rm -f /var/log/user.log /var/log/auth.log
## Mail log files
rm -f /var/log/mail.err /var/log/mail.info /var/log/mail.log /var/log/mail.warn
## System log files
rm -f /var/log/daemon.log /var/log/syslog /var/log/messages
# Restart Rsyslog service
/etc/init.d/rsyslog restart
### Logrotate ###
# Install new Logrotate configuration
if [ -f "${LOGROTATE_FILE}" ]; then
cp "${LOGROTATE_CONF}" "${LOGROTATE_FILE}"
fi
cp "${LOGROTATE_SYSLOG_CONF}" "${LOGROTATE_SYSLOG_FILE}"
cp "${LOGROTATE_APTITUDE_CONF}" "${LOGROTATE_APTITUDE_FILE}"
cp "${LOGROTATE_DPKG_CONF}" "${LOGROTATE_DPKG_FILE}"
# Create an archive directory for some log files (aptitude, dpkg, …)
mkdir -p -- /var/log/old_logs