forked from hercules-team/augeas
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_logrotate.aug
266 lines (244 loc) · 7.33 KB
/
test_logrotate.aug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
module Test_logrotate =
test Logrotate.body get "\n{\n monthly\n}" =
{ "schedule" = "monthly" }
test Logrotate.rule get "/var/log/foo\n{\n monthly\n}\n" =
{ "rule"
{ "file" = "/var/log/foo" }
{ "schedule" = "monthly" } }
test Logrotate.rule get "/var/log/foo /var/log/bar\n{\n monthly\n}\n" =
{ "rule"
{ "file" = "/var/log/foo" }
{ "file" = "/var/log/bar" }
{ "schedule" = "monthly" } }
let conf = "# 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
tabooext + .old .orig .ignore
# 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
/var/log/wtmp2
{
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp /var/log/btmp* {
missingok
# ftpd doesn't handle SIGHUP properly
monthly
create 0664 root utmp
rotate 1
}
/var/log/vsftpd.log {
# ftpd doesn't handle SIGHUP properly
nocompress
missingok
notifempty
rotate 4
weekly
}
/var/log/apache2/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
prerotate
if [ -f /var/run/apache2.pid ]; then
/etc/init.d/apache2 restart > /dev/null
fi
endscript
}
/var/log/mailman/digest {
su root list
monthly
missingok
create 0664 list list
rotate 4
compress
delaycompress
sharedscripts
postrotate
[ -f '/var/run/mailman/mailman.pid' ] && /usr/lib/mailman/bin/mailmanctl -q reopen || exit 0
endscript
}
/var/log/ntp {
compress
dateext
maxage 365
rotate 99
size=+2048k
notifempty
missingok
copytruncate
postrotate
chmod 644 /var/log/ntp
endscript
}
"
test Logrotate.lns get conf =
{ "#comment" = "see man logrotate for details" }
{ "#comment" = "rotate log files weekly" }
{ "schedule" = "weekly" }
{}
{ "#comment" = "keep 4 weeks worth of backlogs" }
{ "rotate" = "4" }
{}
{ "#comment" = "create new (empty) log files after rotating old ones" }
{ "create" }
{}
{ "#comment" = "uncomment this if you want your log files compressed" }
{ "#comment" = "compress" }
{}
{ "tabooext" = "+" { ".old" } { ".orig" } { ".ignore" } }
{}
{ "#comment" = "packages drop log rotation information into this directory" }
{ "include" = "/etc/logrotate.d" }
{}
{ "#comment" = "no packages own wtmp, or btmp -- we'll rotate them here" }
{ "rule"
{ "file" = "/var/log/wtmp" }
{ "file" = "/var/log/wtmp2" }
{ "missingok" = "missingok" }
{ "schedule" = "monthly" }
{ "create"
{ "mode" = "0664" }
{ "owner" = "root" }
{ "group" = "utmp" } }
{ "rotate" = "1" } }
{}
{ "rule"
{ "file" = "/var/log/btmp" }
{ "file" = "/var/log/btmp*" }
{ "missingok" = "missingok" }
{ "#comment" = "ftpd doesn't handle SIGHUP properly" }
{ "schedule" = "monthly" }
{ "create"
{ "mode" = "0664" }
{ "owner" = "root" }
{ "group" = "utmp" } }
{ "rotate" = "1" } }
{ "rule"
{ "file" = "/var/log/vsftpd.log" }
{ "#comment" = "ftpd doesn't handle SIGHUP properly" }
{ "compress" = "nocompress" }
{ "missingok" = "missingok" }
{ "ifempty" = "notifempty" }
{ "rotate" = "4" }
{ "schedule" = "weekly" } }
{}
{ "rule"
{ "file" = "/var/log/apache2/*.log" }
{ "schedule" = "weekly" }
{ "missingok" = "missingok" }
{ "rotate" = "52" }
{ "compress" = "compress" }
{ "delaycompress" = "delaycompress" }
{ "ifempty" = "notifempty" }
{ "create"
{ "mode" = "640" }
{ "owner" = "root" }
{ "group" = "adm" } }
{ "sharedscripts" = "sharedscripts" }
{ "prerotate" = " if [ -f /var/run/apache2.pid ]; then
/etc/init.d/apache2 restart > /dev/null
fi" } }
{ "rule"
{ "file" = "/var/log/mailman/digest" }
{ "su"
{ "owner" = "root" }
{ "group" = "list" } }
{ "schedule" = "monthly" }
{ "missingok" = "missingok" }
{ "create"
{ "mode" = "0664" }
{ "owner" = "list" }
{ "group" = "list" } }
{ "rotate" = "4" }
{ "compress" = "compress" }
{ "delaycompress" = "delaycompress" }
{ "sharedscripts" = "sharedscripts" }
{ "postrotate" = " [ -f '/var/run/mailman/mailman.pid' ] && /usr/lib/mailman/bin/mailmanctl -q reopen || exit 0" } }
{ "rule"
{ "file" = "/var/log/ntp" }
{ "compress" = "compress" }
{ "dateext" = "dateext" }
{ "maxage" = "365" }
{ "rotate" = "99" }
{ "size" = "+2048k" }
{ "ifempty" = "notifempty" }
{ "missingok" = "missingok" }
{ "copytruncate" = "copytruncate" }
{ "postrotate" = " chmod 644 /var/log/ntp" } }
test Logrotate.lns get "/var/log/file {\n dateext\n}\n" =
{ "rule"
{ "file" = "/var/log/file" }
{ "dateext" = "dateext" } }
(* Make sure 'minsize 1M' works *)
test Logrotate.lns get "/avr/log/wtmp {\n minsize 1M\n}\n" =
{ "rule"
{ "file" = "/avr/log/wtmp" }
{ "minsize" = "1M" } }
(* '=' is a legal separator, file names can be indented *)
test Logrotate.lns get " \t /file {\n size=5M\n}\n" =
{ "rule"
{ "file" = "/file" }
{ "size" = "5M" } }
(* Can leave owner/group off a create statement *)
test Logrotate.lns get "/file {
create 600\n}\n" =
{ "rule"
{ "file" = "/file" }
{ "create"
{ "mode" = "600" } } }
test Logrotate.lns put "/file {\n create 600\n}\n" after
set "/rule/create/owner" "user"
= "/file {\n create 600 user\n}\n"
(* The newline at the end of a script is optional *)
test Logrotate.lns put "/file {\n size=5M\n}\n" after
set "/rule/prerotate" "\tfoobar"
=
"/file {
size=5M
\tprerotate
\tfoobar
\tendscript\n}\n"
test Logrotate.lns put "/file {\n size=5M\n}\n" after
set "/rule/prerotate" "\tfoobar\n"
=
"/file {
size=5M
\tprerotate
\tfoobar\n
\tendscript\n}\n"
(* Bug #101: whitespace at the end of the line *)
test Logrotate.lns get "/file {\n missingok \t\n}\n" =
{ "rule"
{ "file" = "/file" }
{ "missingok" = "missingok" } }
(* Bug #104: file names can be separated by newlines *)
let conf2 = "/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
{
weekly
}
"
test Logrotate.lns get conf2 =
{ "rule"
{ "file" = "/var/log/mail.info" }
{ "file" = "/var/log/mail.warn" }
{ "file" = "/var/log/mail.err" }
{ "schedule" = "weekly" } }