Logrotate is a system utility that rotates, compresses, removes and mails

system log files

PR:		15759
Submitted by:	Yuan-Chen Cheng <ycheng@ml.tw.freebsd.org>
This commit is contained in:
Chris D. Faulhaber
1999-12-30 12:35:51 +00:00
parent 281777db42
commit d4767b5f68
11 changed files with 199 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
# New ports collection makefile for: logrotate
# Version required: 3.3
# Date Created: 29 Dec 1999
# Whom: Yuan-Chen Cheng <ycheng@sinica.edu.tw>
#
# $FreeBSD$
#
DISTNAME= logrotate-3.3
CATEGORIES= sysutils
MASTER_SITES= ftp://ftp.redhat.com/pub/redhat/current/SRPMS/SRPMS/ \
ftp://ftp.cdrom.com/pub/linux/redhat/current/SRPMS/SRPMS/
EXTRACT_SUFX= -1.src.rpm
MAINTAINER= ycheng@sinica.edu.tw
BUILD_DEPENDS= ${LOCALBASE}/bin/rpm2cpio:${PORTSDIR}/misc/rpm \
${LOCALBASE}/lib/libpopt.a:${PORTSDIR}/devel/popt
USE_GMAKE= yes
MAN8= logrotate.8
MANCOMPRESSED= no
do-extract:
@${RM} -rf ${WRKDIR}
@${MKDIR} ${WRKDIR}
@rpm2cpio ${_DISTDIR}${DISTFILES} | (cd ${WRKDIR}; cpio -i)
@tar -xzf ${WRKDIR}/${DISTNAME}.tar.gz -C ${WRKDIR}
post-install:
@${MKDIR} ${PREFIX}/etc/logrotate.d
@${SED} -e 's|__PREFIX__|${PREFIX}|' \
< ${FILESDIR}/logrotate.conf.sample > ${PREFIX}/etc/logrotate.conf.sample
@${INSTALL_DATA} ${FILESDIR}/syslog.sample ${PREFIX}/etc/logrotate.d/
.include <bsd.port.mk>

View File

@@ -0,0 +1 @@
MD5 (logrotate-3.3-1.src.rpm) = 3a399653214c9dd6b23363d4ff68b633

View File

@@ -0,0 +1,25 @@
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# send errors to root
errors root
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
compress
# RPM packages drop log rotation information into this directory
include __PREFIX__/etc/logrotate.d
/var/log/lastlog {
monthly
rotate 1
}
# system-specific logs may be configured here

View File

@@ -0,0 +1,12 @@
--- config.c.orig Tue Dec 28 15:24:25 1999
+++ config.c Tue Dec 28 15:26:54 1999
@@ -1,9 +1,7 @@
-#include <alloca.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <getopt.h>
#include <glob.h>
#include <grp.h>
#include <pwd.h>

View File

@@ -0,0 +1,29 @@
--- Makefile.orig Wed Dec 30 03:29:13 1998
+++ Makefile Tue Dec 28 15:35:52 1999
@@ -2,11 +2,13 @@
CVSTAG = r$(subst .,-,$(VERSION))
CFLAGS = -Wall -D_GNU_SOURCE -DVERSION=\"$(VERSION)\" $(RPM_OPT_FLAGS)
PROG = logrotate
-BINDIR = /usr/sbin
-MANDIR = /usr/man
+BINDIR = sbin
+MANDIR = man
MAN = logrotate.8
LOADLIBES = -lpopt
+LOADLIBES += -L/usr/local/lib
+CFLAGS += -I/usr/local/include
#--------------------------------------------------------------------------
OBJS = logrotate.o log.o config.o basenames.o
@@ -40,8 +42,8 @@
[ -d $(PREFIX)/$(MANDIR) ] || mkdir -p $(PREFIX)/$(MANDIR)
[ -d $(PREFIX)/$(MANDIR)/man8 ] || mkdir -p $(PREFIX)/$(MANDIR)/man8
- install -s -m 755 $(PROG) $(PREFIX)/$(BINDIR)
- install -m 644 $(MAN) $(PREFIX)/$(MANDIR)/man`echo $(MAN) | sed "s/.*\.//"`/$(MAN)
+ install -c -s -m 755 $(PROG) $(PREFIX)/$(BINDIR)
+ install -c -m 644 $(MAN) $(PREFIX)/$(MANDIR)/man`echo $(MAN) | sed "s/.*\.//"`/$(MAN)
co:
co RCS/*,v

View File

@@ -0,0 +1,22 @@
--- logrotate.c.orig Thu Jun 17 04:37:19 1999
+++ logrotate.c Wed Dec 29 11:31:57 1999
@@ -1,9 +1,7 @@
-#include <alloca.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <getopt.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
@@ -457,6 +455,9 @@
hasErrors = 1;
}
}
+
+ message(MESS_DEBUG, "sleep 10 to wait daemon close log\n");
+ sleep(10);
if (!hasErrors && !log->rotateCount) {
message(MESS_DEBUG, "removing rotated log (rotateCount == 0)");

View File

@@ -0,0 +1,11 @@
--- logrotate.h.orig Tue Dec 28 15:55:44 1999
+++ logrotate.h Tue Dec 28 15:55:56 1999
@@ -12,7 +12,7 @@
#define LOG_FLAG_MISSINGOK (1 << 5)
#define LOG_FLAG_MAILFIRST (1 << 6)
-#define DEFAULT_MAIL_COMMAND "/bin/mail -s"
+#define DEFAULT_MAIL_COMMAND "/usr/bin/mail -s"
#define COMPRESS_COMMAND "gzip -9"
#define COMPRESS_EXT ".gz"
#define UNCOMPRESS_PIPE "gunzip"

View File

@@ -0,0 +1,53 @@
/var/cron/log {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/amd.log {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/kerberos.log {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/lpd-errs {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/maillog {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/sendmail.st {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/messages {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/slip.log {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
/var/log/ppp.log {
postrotate
/usr/bin/killall -HUP syslogd
endscript
}

View File

@@ -0,0 +1 @@
Daemon to rotate, compress, remove and mail system log files

View File

@@ -0,0 +1,5 @@
Daemon to rotate, compress, remove and mail system log files.
I try to make it work just like /usr/sbin/newsyslog.
With logrotate, you can mail syslog and execute command
before or after logrotate.

View File

@@ -0,0 +1,4 @@
sbin/logrotate
etc/logrotate.conf.sample
etc/logrotate.d/syslog.sample
@dirrm etc/logrotate.d