diff -Nur -x '*.orig' -x '*.rej' e-smith-base-4.18.0/createlinks mezzanine_patched_e-smith-base-4.18.0/createlinks --- e-smith-base-4.18.0/createlinks 2007-03-26 16:11:58.000000000 -0400 +++ mezzanine_patched_e-smith-base-4.18.0/createlinks 2007-03-26 16:11:34.000000000 -0400 @@ -371,6 +371,7 @@ $event = "post-install"; +event_link("rotate_timestamped_logfiles", $event, "05"); event_link("init-accounts", $event, "05"); event_link("init-passwords", $event, "10"); event_link("conf-startup", $event, "10"); @@ -383,6 +384,7 @@ $event = "post-upgrade"; +event_link("rotate_timestamped_logfiles", $event, "05"); event_link("init-accounts", $event, "05"); event_link("conf-startup", $event, "10"); event_link("user-lock-passwd", $event, "15"); @@ -491,6 +493,7 @@ $event = "logrotate"; +event_link("rotate_timestamped_logfiles", $event, "05"); event_link("purge-old-logs", $event, "75"); safe_symlink("reload", "root/etc/e-smith/events/$event/services2adjust/syslog"); diff -Nur -x '*.orig' -x '*.rej' e-smith-base-4.18.0/root/etc/e-smith/events/actions/rotate_timestamped_logfiles mezzanine_patched_e-smith-base-4.18.0/root/etc/e-smith/events/actions/rotate_timestamped_logfiles --- e-smith-base-4.18.0/root/etc/e-smith/events/actions/rotate_timestamped_logfiles 1969-12-31 19:00:00.000000000 -0500 +++ mezzanine_patched_e-smith-base-4.18.0/root/etc/e-smith/events/actions/rotate_timestamped_logfiles 2007-03-26 15:50:34.000000000 -0400 @@ -0,0 +1,76 @@ +#! /usr/bin/perl -w +#---------------------------------------------------------------------- +# copyright (C) 2003-2007 Mitel Networks Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#---------------------------------------------------------------------- + +use strict; +use File::Find; +use File::Copy; + +sub setup_logfile_symlink; + +my $event = shift or die "Event name is required\n"; + +my $logfile_dir = "/etc/e-smith/events/$event/logfiles2timestamp"; +if (-d $logfile_dir) +{ + # Prepare log rotation if required + chdir $logfile_dir or die "Could not chdir to $logfile_dir: $!\n";; + find({ + no_chdir => 1, + follow => 0, + wanted => \&setup_logfile_symlink, + }, + '.' + ); +} + +exit 0; + +sub setup_logfile_symlink +{ + return unless -f $_; + s/^\.//; + my $filename = $_; + + # Set up filenames to be used by syslog. We first set up symlinks + # with known names, then use the value of the symlink when we + # expand the configuration files + my $time = time(); + + if (-f "${filename}" and ! -l "${filename}") + { + my ($sec,$min,$hour,$mday,$mon,$year) = localtime($time - 1); + my $target = sprintf("%s.%04d%02d%02d%02d%02d%02d", + $filename, $year+1900, $mon+1, $mday, $hour, $min, $sec); + move("${filename}", "${target}") or + die "Could not move ${filename} to " . + "${target}"; + } + my ($sec,$min,$hour,$mday,$mon,$year) = localtime($time); + my $target = sprintf("%s.%04d%02d%02d%02d%02d%02d", + $filename, $year+1900, $mon+1, $mday, $hour, $min, $sec); + + if (-l "${filename}") + { + unlink("${filename}") or + warn "Could not unlink ${filename}"; + } + symlink("${target}", "${filename}") or + warn "Could not symlink ${target} to ${filename}"; +}