Create a tiny archive used as a post-install script at the end of a

preseed.
This commit is contained in:
Jeremy Gardais 2015-04-01 16:24:07 +02:00
parent b576f47463
commit a874b585f9
8 changed files with 285 additions and 0 deletions

BIN
preseed/finish.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,8 @@
/var/log/aptitude {
rotate 6
weekly
compress
missingok
notifempty
olddir /var/log/old_logs
}

View File

@ -0,0 +1,20 @@
/var/log/dpkg.log {
weekly
rotate 12
compress
delaycompress
missingok
notifempty
create 644 root root
olddir /var/log/old_logs
}
/var/log/alternatives.log {
weekly
rotate 12
compress
delaycompress
missingok
notifempty
create 644 root root
olddir /var/log/old_logs
}

View File

@ -0,0 +1,43 @@
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
compress
# compress only from the second log file
delaycompress
# use date as a suffix of the rotated file
dateext
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
missingok
notifempty
monthly
create 0664 root utmp
olddir /var/log/old_logs
rotate 3
}
/var/log/btmp {
missingok
notifempty
monthly
create 0664 root utmp
olddir /var/log/old_logs
rotate 3
}
# system-specific logs may be configured here
# See /etc/logrotate.d/rsyslog

View File

@ -0,0 +1,76 @@
# Ensure to rotate all log files (old and new logpath from Rsyslog)
/var/log/syslog/syslog
/var/log/syslog/syslog.log
/var/log/syslog/daemon.log
/var/log/syslog/local0.log
/var/log/syslog/local1.log
/var/log/syslog/local2.log
/var/log/syslog/local3.log
/var/log/syslog/local4.log
/var/log/syslog/local5.log
/var/log/syslog/local6.log
/var/log/syslog/local7.log
/var/log/syslog/uucp.log
/var/log/syslog
/var/log/syslog.log
/var/log/daemon.log
/var/log/local0.log
/var/log/local1.log
/var/log/local2.log
/var/log/local3.log
/var/log/local4.log
/var/log/local5.log
/var/log/local6.log
/var/log/local7.log
/var/log/uucp.log
{
rotate 7
daily
missingok
notifempty
compress
delaycompress
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}
/var/log/cron/cron.log
/var/log/cron/mark.log
/var/log/kernel/kern.log
/var/log/kernel/kernel.log
/var/log/lpr/lpr.log
/var/log/mail/*.log
/var/log/security/auth.log
/var/log/security/authpriv.log
/var/log/security/user.log
/var/log/messages/messages
/var/log/news/news.log
/var/log/cron.log
/var/log/mark.log
/var/log/kern.log
/var/log/kernel.log
/var/log/lpr.log
/var/log/mail.log
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/auth.log
/var/log/authpriv.log
/var/log/user.log
/var/log/messages
/var/log/debug
{
rotate 4
maxsize 250k
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}

52
preseed/finish/post.sh Executable file
View File

@ -0,0 +1,52 @@
#!/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

View File

@ -0,0 +1,58 @@
# /etc/rsyslog.conf Configuration file for rsyslog.
# More information http://wiki.rsyslog.com/index.php/
#
# For more information see
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#################
#### MODULES ####
#################
$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog # provides kernel logging support
#$ModLoad immark # provides --MARK-- message capability
$KLogPath /proc/kmsg
# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514
# provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514
###########################
#### GLOBAL DIRECTIVES ####
###########################
#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# Filter duplicated messages
$RepeatedMsgReduction on
#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf
###############
#### RULES ####
###############
# See /etc/rsyslog.d/syslog.conf

View File

@ -0,0 +1,28 @@
# Default rules for rsyslog.
#
# For more information see rsyslog.conf(5) and /etc/rsyslog.conf
#----------------------------------------------------------------------------
# Fichier de configuration du daemon syslogd
#----------------------------------------------------------------------------
kern.* /var/log/kernel/kernel.log
user.* /var/log/security/user.log
mail.* /var/log/mail/mail.log
daemon.* /var/log/syslog/daemon.log
auth.* /var/log/security/auth.log
lpr.* /var/log/lpr/lpr.log
news.* /var/log/news/news.log
uucp.* /var/log/syslog/uucp.log
cron.* /var/log/cron/cron.log
mark.* /var/log/cron/mark.log
local0.* /var/log/syslog/local0.log
local1.* /var/log/syslog/local1.log
local2.* /var/log/syslog/local2.log
local3.* /var/log/syslog/local3.log
local4.* /var/log/syslog/local4.log
local5.* /var/log/syslog/local5.log
local6.* /var/log/syslog/local6.log
local7.* /var/log/syslog/local7.log
syslog.* /var/log/syslog/syslog.log
authpriv.* /var/log/security/authpriv.log
*.=info;*.=notice /var/log/messages/messages