1 |
slords |
1.1 |
diff -Nur -x '*.orig' -x '*.rej' e-smith-base-4.18.0/createlinks mezzanine_patched_e-smith-base-4.18.0/createlinks |
2 |
|
|
--- e-smith-base-4.18.0/createlinks 2007-03-26 16:11:58.000000000 -0400 |
3 |
|
|
+++ mezzanine_patched_e-smith-base-4.18.0/createlinks 2007-03-26 16:11:34.000000000 -0400 |
4 |
|
|
@@ -371,6 +371,7 @@ |
5 |
|
|
|
6 |
|
|
$event = "post-install"; |
7 |
|
|
|
8 |
|
|
+event_link("rotate_timestamped_logfiles", $event, "05"); |
9 |
|
|
event_link("init-accounts", $event, "05"); |
10 |
|
|
event_link("init-passwords", $event, "10"); |
11 |
|
|
event_link("conf-startup", $event, "10"); |
12 |
|
|
@@ -383,6 +384,7 @@ |
13 |
|
|
|
14 |
|
|
$event = "post-upgrade"; |
15 |
|
|
|
16 |
|
|
+event_link("rotate_timestamped_logfiles", $event, "05"); |
17 |
|
|
event_link("init-accounts", $event, "05"); |
18 |
|
|
event_link("conf-startup", $event, "10"); |
19 |
|
|
event_link("user-lock-passwd", $event, "15"); |
20 |
|
|
@@ -491,6 +493,7 @@ |
21 |
|
|
|
22 |
|
|
$event = "logrotate"; |
23 |
|
|
|
24 |
|
|
+event_link("rotate_timestamped_logfiles", $event, "05"); |
25 |
|
|
event_link("purge-old-logs", $event, "75"); |
26 |
|
|
|
27 |
|
|
safe_symlink("reload", "root/etc/e-smith/events/$event/services2adjust/syslog"); |
28 |
|
|
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 |
29 |
|
|
--- e-smith-base-4.18.0/root/etc/e-smith/events/actions/rotate_timestamped_logfiles 1969-12-31 19:00:00.000000000 -0500 |
30 |
|
|
+++ 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 |
31 |
|
|
@@ -0,0 +1,76 @@ |
32 |
|
|
+#! /usr/bin/perl -w |
33 |
|
|
+#---------------------------------------------------------------------- |
34 |
|
|
+# copyright (C) 2003-2007 Mitel Networks Corporation |
35 |
|
|
+# |
36 |
|
|
+# This program is free software; you can redistribute it and/or modify |
37 |
|
|
+# it under the terms of the GNU General Public License as published by |
38 |
|
|
+# the Free Software Foundation; either version 2 of the License, or |
39 |
|
|
+# (at your option) any later version. |
40 |
|
|
+# |
41 |
|
|
+# This program is distributed in the hope that it will be useful, |
42 |
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
43 |
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
44 |
|
|
+# GNU General Public License for more details. |
45 |
|
|
+# |
46 |
|
|
+# You should have received a copy of the GNU General Public License |
47 |
|
|
+# along with this program; if not, write to the Free Software |
48 |
|
|
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
49 |
|
|
+# |
50 |
|
|
+#---------------------------------------------------------------------- |
51 |
|
|
+ |
52 |
|
|
+use strict; |
53 |
|
|
+use File::Find; |
54 |
|
|
+use File::Copy; |
55 |
|
|
+ |
56 |
|
|
+sub setup_logfile_symlink; |
57 |
|
|
+ |
58 |
|
|
+my $event = shift or die "Event name is required\n"; |
59 |
|
|
+ |
60 |
|
|
+my $logfile_dir = "/etc/e-smith/events/$event/logfiles2timestamp"; |
61 |
|
|
+if (-d $logfile_dir) |
62 |
|
|
+{ |
63 |
|
|
+ # Prepare log rotation if required |
64 |
|
|
+ chdir $logfile_dir or die "Could not chdir to $logfile_dir: $!\n";; |
65 |
|
|
+ find({ |
66 |
|
|
+ no_chdir => 1, |
67 |
|
|
+ follow => 0, |
68 |
|
|
+ wanted => \&setup_logfile_symlink, |
69 |
|
|
+ }, |
70 |
|
|
+ '.' |
71 |
|
|
+ ); |
72 |
|
|
+} |
73 |
|
|
+ |
74 |
|
|
+exit 0; |
75 |
|
|
+ |
76 |
|
|
+sub setup_logfile_symlink |
77 |
|
|
+{ |
78 |
|
|
+ return unless -f $_; |
79 |
|
|
+ s/^\.//; |
80 |
|
|
+ my $filename = $_; |
81 |
|
|
+ |
82 |
|
|
+ # Set up filenames to be used by syslog. We first set up symlinks |
83 |
|
|
+ # with known names, then use the value of the symlink when we |
84 |
|
|
+ # expand the configuration files |
85 |
|
|
+ my $time = time(); |
86 |
|
|
+ |
87 |
|
|
+ if (-f "${filename}" and ! -l "${filename}") |
88 |
|
|
+ { |
89 |
|
|
+ my ($sec,$min,$hour,$mday,$mon,$year) = localtime($time - 1); |
90 |
|
|
+ my $target = sprintf("%s.%04d%02d%02d%02d%02d%02d", |
91 |
|
|
+ $filename, $year+1900, $mon+1, $mday, $hour, $min, $sec); |
92 |
|
|
+ move("${filename}", "${target}") or |
93 |
|
|
+ die "Could not move ${filename} to " . |
94 |
|
|
+ "${target}"; |
95 |
|
|
+ } |
96 |
|
|
+ my ($sec,$min,$hour,$mday,$mon,$year) = localtime($time); |
97 |
|
|
+ my $target = sprintf("%s.%04d%02d%02d%02d%02d%02d", |
98 |
|
|
+ $filename, $year+1900, $mon+1, $mday, $hour, $min, $sec); |
99 |
|
|
+ |
100 |
|
|
+ if (-l "${filename}") |
101 |
|
|
+ { |
102 |
|
|
+ unlink("${filename}") or |
103 |
|
|
+ warn "Could not unlink ${filename}"; |
104 |
|
|
+ } |
105 |
|
|
+ symlink("${target}", "${filename}") or |
106 |
|
|
+ warn "Could not symlink ${target} to ${filename}"; |
107 |
|
|
+} |