/[smecontribs]/rpms/smeserver-ezmlm-www/contribs10/smeserver-ezmlm-www-2.0.0-bz11909-sme10.patch
ViewVC logotype

Contents of /rpms/smeserver-ezmlm-www/contribs10/smeserver-ezmlm-www-2.0.0-bz11909-sme10.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Sat Mar 19 03:30:10 2022 UTC (2 years, 7 months ago) by jpp
Branch: MAIN
CVS Tags: smeserver-ezmlm-www-2_0_0-5_el7_sme
Changes since 1.2: +5 -0 lines
* Fri Mar 18 2022 Jean-Philippe Pialasse <tests@pialasse.com> 2.0.0-5.sme
- fix ez_search perms  [SME: 11909]
- use KinoSearch1
- create directory indexes

1 diff -Nur --no-dereference smeserver-ezmlm-www-2.0.0.old/createlinks smeserver-ezmlm-www-2.0.0/createlinks
2 --- smeserver-ezmlm-www-2.0.0.old/createlinks 2022-03-15 16:53:00.000000000 -0400
3 +++ smeserver-ezmlm-www-2.0.0/createlinks 2022-03-16 00:25:48.158000000 -0400
4 @@ -5,5 +5,31 @@
5
6 my $event="smeserver-ezmlm-www-update";
7 templates2events("/etc/httpd/conf/httpd.conf", $event);
8 +templates2events("/opt/mailinglist/search/ez_indexer.pl", $event);
9 +templates2events("/opt/mailinglist/config.pm", $event);
10 safe_symlink("restart","root/etc/e-smith/events/$event/services2adjust/httpd-e-smith");
11
12 +templates2events("/opt/mailinglist/search/ez_indexer.pl", qw(
13 + bootstrap-console-save
14 + console-save
15 + email-update
16 + mailinglist-create
17 + mailinglist-update
18 + mailinglist-assign
19 + ));
20 +templates2events("/opt/mailinglist/config.pm", qw(
21 + bootstrap-console-save
22 + console-save
23 + email-update
24 + mailinglist-create
25 + mailinglist-update
26 + mailinglist-assign
27 + ));
28 +foreach (qw(
29 + smeserver-ezmlm-www-update
30 + mailinglist-create
31 + mailinglist-update
32 + mailinglist-assign
33 + )) {
34 +event_link("ezw-search-create", $_, "50");
35 +}
36 diff -Nur --no-dereference smeserver-ezmlm-www-2.0.0.old/root/etc/cron.hourly/ezw-search smeserver-ezmlm-www-2.0.0/root/etc/cron.hourly/ezw-search
37 --- smeserver-ezmlm-www-2.0.0.old/root/etc/cron.hourly/ezw-search 1969-12-31 19:00:00.000000000 -0500
38 +++ smeserver-ezmlm-www-2.0.0/root/etc/cron.hourly/ezw-search 2022-03-16 00:19:01.108000000 -0400
39 @@ -0,0 +1,3 @@
40 +#!/bin/bash
41 +cd /opt/mailinglist/search
42 +./ez_indexer.pl --update
43 diff -Nur --no-dereference smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/events/actions/ezw-search-create smeserver-ezmlm-www-2.0.0/root/etc/e-smith/events/actions/ezw-search-create
44 --- smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/events/actions/ezw-search-create 1969-12-31 19:00:00.000000000 -0500
45 +++ smeserver-ezmlm-www-2.0.0/root/etc/e-smith/events/actions/ezw-search-create 2022-03-16 00:22:45.486000000 -0400
46 @@ -0,0 +1,3 @@
47 +#!/bin/bash
48 +cd /opt/mailinglist/search
49 +/opt/mailinglist/search/ez_indexer.pl --create --verbose
50 diff -Nur --no-dereference smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/templates/opt/mailinglist/config.pm smeserver-ezmlm-www-2.0.0/root/etc/e-smith/templates/opt/mailinglist/config.pm
51 --- smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/templates/opt/mailinglist/config.pm 1969-12-31 19:00:00.000000000 -0500
52 +++ smeserver-ezmlm-www-2.0.0/root/etc/e-smith/templates/opt/mailinglist/config.pm 2022-03-16 00:13:17.308000000 -0400
53 @@ -0,0 +1,99 @@
54 +#---------------------------------------------------------------------------
55 +# ezmlm-www (configuration file - see README)
56 +#---------------------------------------------------------------------------
57 +
58 +#---------------------------------------------------------------------------
59 +#-- Mailing list configuration goes here:
60 +{
61 + use esmith::AccountsDB;
62 + my $adb = esmith::AccountsDB->open_ro();
63 + $OUT = "";
64 + my @sortings=('thread' , 'date' , 'subject' );
65 + foreach my $list ($adb->get_all_by_prop(type => 'mailinglist'))
66 + {
67 + next if (($list->prop('DisplayArchives') || 'disabled') ne 'enabled');
68 + my $key= $list->key;
69 + my $dompart=$list->prop('Domain');
70 + my $name = "$key\@$dompart" ;
71 + my $conceal_senders = ( ( $list->prop('conceal_senders') || 'enabled' ) eq 'enabled')? 1 : 0;
72 + my $Description = $list->prop('Description') || "no description";
73 + my $default_sorting = ( $list->prop('default_sorting') ~~ @sortings ) ? $list->prop('default_sorting') : 'thread';
74 + my $show_html = (( $list->prop('show_html') || 'enabled') eq 'enabled')? 1 : 0;
75 + my $highlight = (( $list->prop('highlight') ||'enabled') eq 'enabled')? 1 : 0;
76 + my $show_inline_images = (( $list->prop('show_inline_images') || 'enabled') eq 'enabled')? 1 : 0;
77 + my $subscription_info = (( $list->prop('subscription_info') || 'disabled') eq 'enabled') ? 1 : 0;
78 + my $descending_by_default = (( $list->prop('descending_by_default') || 'enabled') eq 'enabled')? 1 : 0;
79 +
80 + $OUT.=<<"END_TXT";
81 +push \@\$lists, {
82 + name => '$name',
83 + local_part => '$key',
84 + host_part => '$dompart',
85 + description => '$Description',
86 + archive => Mail::Ezmlm::Archive->new('/home/e-smith/files/ezmlm/lists/$key'),
87 + conceal_senders => $conceal_senders,
88 + subscription_info => $subscription_info ,
89 + descending_by_default => 1,
90 + default_sorting => '$default_sorting', #may be 'thread', 'date' or 'subject'
91 + show_html => $show_html,
92 + highlight => $highlight,
93 + show_inline_images => $show_inline_images
94 +};
95 +END_TXT
96 + }
97 +
98 +}
99 +
100 +#---------------------------------------------------------------------------
101 +#-- This option specifies the language used for localized strings:
102 +
103 +$lang = '{
104 +my @langs = ('bg', 'de', 'en', 'es' , 'fr', 'it', 'no', 'pt' , 'tr', 'zh');
105 +my $syslang = (( substr($sysconfig{'Language'}, 0, 2) || 'unknown' ) ~~ @langs ) ? substr($sysconfig{'Language'}, 0, 2) : 'en' ;
106 +my $langu = (( $ezmlm{'lang'} || 'unknown') ~~ @langs) ? $ezmlm{'lang'} : $syslang;
107 +return $langu;
108 +}';
109 +
110 +#---------------------------------------------------------------------------
111 +#-- To enable vpopmail support just uncomment the following line:
112 +#-- (this will disable the configuration done with the "push @$lists"
113 +#-- syntax above, as all information will be taken from vpopmail local
114 +#-- database and the %Config defaults below.)
115 +
116 +#use vpopmail;
117 +
118 +
119 +#---------------------------------------------------------------------------
120 +#--Additional configuration options:
121 +{
122 + my $ListServerName = $ezmlm{'ListServerName'} || $DomainName ;
123 + $OUT.=<<"END_TXT";
124 +%Config = (
125 + ListServerName => '$ListServerName',
126 +
127 + #--These settings will be used for vpopmail-based mailing lists:
128 + # NOT IN USE WITH SME #
129 + DefaultVpopmailSettings => {
130 + conceal_senders => 1,
131 + subscription_info => 1,
132 + descending_by_default => 1,
133 + default_sorting => 'thread', #may be 'thread', 'date' or 'subject'
134 + show_html => 1,
135 + highlight => 1
136 + },
137 + VpopmailAccess => {
138 + default_policy => 'allow',
139 + allow_lists => [],
140 + deny_lists => [],
141 + allow_domains => [],
142 + deny_domains => []
143 + },
144 +
145 + #--CSS web path:
146 + CSSPath => 'style.css'
147 +);
148 +END_TXT
149 +
150 +}
151 +
152 +1;
153 diff -Nur --no-dereference smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/templates/opt/mailinglist/search/ez_indexer.pl smeserver-ezmlm-www-2.0.0/root/etc/e-smith/templates/opt/mailinglist/search/ez_indexer.pl
154 --- smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/templates/opt/mailinglist/search/ez_indexer.pl 1969-12-31 19:00:00.000000000 -0500
155 +++ smeserver-ezmlm-www-2.0.0/root/etc/e-smith/templates/opt/mailinglist/search/ez_indexer.pl 2022-03-16 00:12:49.235000000 -0400
156 @@ -0,0 +1,230 @@
157 +#!/usr/bin/perl -w
158 +# ===========================================================================
159 +# ez_indexer.pl
160 +#
161 +# Author: Alessandro Ranellucci <aar@cpan.org>
162 +# Copyright (c) 2005-06.
163 +#
164 +# see http://ezmlm-www.sourceforge.net
165 +#-----------------------------------------------------------------------
166 +#
167 +
168 +use strict;
169 +use warnings;
170 +our $VERSION = 1.2.1;
171 +
172 +use Date::Parse 'str2time';
173 +use Email::Simple;
174 +use Getopt::Long;
175 +use Mail::Ezmlm::Archive;
176 +our @Lists = ();
177 +
178 +#---------------------------------------------------------
179 +#-- CONFIGURATION
180 +#--
181 +#-- Choose here your search engine. This can be 'kinosearch'
182 +#-- or 'plucene'.
183 +our $Engine = '{
184 +my @langs = ('kinosearch', 'plucene');
185 +my $langu = (( $ezmlm{'Engine'} || 'unknown') ~~ @langs) ? $ezmlm{'Engine'} : 'kinosearch';
186 +return $langu;
187 +}';
188 +#-- Repeat the following block for each list you want to
189 +#-- index.
190 +#--
191 +{
192 + use esmith::AccountsDB;
193 + my $adb = esmith::AccountsDB->open_ro();
194 + $OUT = "";
195 + my @sortings=('thread' , 'date' , 'subject' );
196 + foreach my $list ($adb->get_all_by_prop(type => 'mailinglist'))
197 + {
198 + #next if (($list->prop('DisplayArchives') || 'disabled') ne 'enabled');
199 + my $key= $list->key;
200 + $OUT .= <<"END_TEXT";
201 +push \@Lists, {
202 + list_dir => '/home/e-smith/files/ezmlm/lists/$key',
203 + index_dir => '/opt/mailinglist/search/indexes/$key'
204 +};
205 +END_TEXT
206 + }
207 +}
208 +#--
209 +#-- END CONFIGURATION
210 +#---------------------------------------------------------
211 +
212 +{
213 +$OUT= <<'END_TEXT';
214 +# DO NOT TOUCH ANYTHING BELOW THIS LINE
215 +my %opt = ();
216 +usage(1) unless GetOptions( \%opt, qw/verbose|v create|c update|u help|h/ );
217 +usage(0) if $opt{help};
218 +usage(1) unless ($opt{create} or $opt{update});
219 +sub usage {
220 + my $rv = shift;
221 + print STDERR <<USAGE;
222 +Usage: ez_indexer.pl COMMAND [OPTS]
223 +
224 +COMMAND may be:
225 + -c, --create Creates a new index
226 + -u, --update Updates an existing index
227 +
228 +OPTS may be:
229 + -h, --help This usage info
230 + -v, --verbose Print verbose information
231 +USAGE
232 +
233 + exit($rv);
234 +}
235 +
236 +if ($Engine eq 'plucene') {
237 + eval q{
238 + use Plucene::Analysis::SimpleAnalyzer;
239 + use Plucene::Document::DateSerializer;
240 + use Plucene::Index::Writer;
241 + };
242 +} elsif ($Engine ne 'kinosearch') {
243 + die "Invalid search engine '$Engine'\n";
244 +}
245 +
246 +LIST: foreach my $list (@Lists) {
247 +
248 + # load the right KinoSearch1 module (for backwards compatibility)
249 + my $kinosearch_version = '';
250 + if ($Engine eq 'kinosearch') {
251 + if ($opt{update} && -e "$list->{index_dir}/kinostats") {
252 + eval q{
253 + use Search::Kinosearch::Kindexer;
254 + };
255 + $kinosearch_version = 'old';
256 + } else {
257 + eval q{
258 + use KinoSearch1::InvIndexer;
259 + use KinoSearch1::Analysis::PolyAnalyzer;
260 + };
261 + $kinosearch_version = 'new';
262 + }
263 + }
264 +
265 + my $archive = Mail::Ezmlm::Archive->new($list->{list_dir})
266 + or die "Failed to load list archive at $list->{list_dir}\n";
267 +
268 + my $writer;
269 + if ($Engine eq 'kinosearch' && $kinosearch_version eq 'old') {
270 + $writer = Search::Kinosearch::Kindexer->new(
271 + -mainpath => $list->{index_dir},
272 + -enable_datetime => 1,
273 + -mode => ($opt{create} ? 'overwrite' : 'update')
274 + #-temp_directory => '/tmp',
275 + );
276 + if ($opt{create}) {
277 + for my $field (qw/subject author/) {
278 + $writer->define_field(
279 + -name => $field,
280 + -lowercase => 1,
281 + -tokenize => 1
282 + );
283 + }
284 + $writer->define_field(
285 + -name => 'message',
286 + -lowercase => 1,
287 + -tokenize => 1,
288 + -store => 0
289 + );
290 + $writer->define_field(
291 + -name => 'date',
292 + -lowercase => 1,
293 + -tokenize => 0
294 + );
295 + }
296 + } elsif ($Engine eq 'kinosearch' && $kinosearch_version eq 'new') {
297 + my $analyzer = KinoSearch1::Analysis::PolyAnalyzer->new( language => 'en' );
298 + $writer = KinoSearch1::InvIndexer->new(
299 + invindex => $list->{index_dir},
300 + create => $opt{create} ? 1 : 0,
301 + analyzer => $analyzer,
302 + );
303 + $writer->spec_field( name => 'msg_id' );
304 + $writer->spec_field( name => 'subject', boost => 3 );
305 + $writer->spec_field( name => 'message', stored => 0 );
306 + $writer->spec_field( name => 'author' );
307 + $writer->spec_field( name => 'date' );
308 + } elsif ($Engine eq 'plucene') {
309 + my $analyzer = Plucene::Analysis::SimpleAnalyzer->new();
310 + $writer = Plucene::Index::Writer->new($list->{index_dir}, $analyzer, 1);
311 + }
312 +
313 + # get first message to index
314 + my $msg_id = 1;
315 + if ($opt{update} && -e "$list->{index_dir}/_ez_offset") {
316 + open COUNTER, "<$list->{index_dir}/_ez_offset";
317 + $msg_id = <COUNTER>;
318 + close COUNTER;
319 + }
320 +
321 + # get last message to index
322 + open MAX, "<$list->{list_dir}/archnum";
323 + my $max_id = <MAX>;
324 + chomp $max_id;
325 + close MAX;
326 +
327 + if ($max_id-$msg_id >= 0) {
328 + print "Indexing messages #$msg_id-#$max_id\n" if $opt{verbose};
329 + } else {
330 + print "No new messages\n" if $opt{verbose};
331 + next LIST;
332 + }
333 +
334 + for (; $msg_id <= $max_id; $msg_id++) {
335 + my $msg = $archive->getmessage($msg_id) or next;
336 + my $message = Email::Simple->new($msg->{text});
337 + print "Processing message #$msg_id\n" if $opt{verbose};
338 +
339 + if ($Engine eq 'kinosearch' && $kinosearch_version eq 'old') {
340 + my $doc = $writer->new_doc("$msg_id");
341 + $doc->set_field(message => $message->body);
342 + $doc->set_field(subject => $message->header("Subject"));
343 + $doc->set_field(author => $message->header("From"));
344 + $doc->set_field(date => $message->header("Date"));
345 + my @t = localtime(str2time($message->header("Date")));
346 + $doc->set_datetime( 1900+$t[5], 1+$t[4], @t[3,2,1,0] );
347 + $writer->add_doc($doc);
348 + } elsif ($Engine eq 'kinosearch' && $kinosearch_version eq 'new') {
349 + my $doc = $writer->new_doc;
350 + $doc->set_value( msg_id => $msg_id );
351 + $doc->set_value( message => $message->body );
352 + $doc->set_value( subject => $message->header("Subject") );
353 + $doc->set_value( author => $message->header("From") );
354 + $doc->set_value( date => $message->header("Date") );
355 + $writer->add_doc($doc);
356 + } elsif ($Engine eq 'plucene') {
357 + my $doc = Plucene::Document->new;
358 + $doc->add(Plucene::Document::Field->Keyword(id => "$msg_id"));
359 + $doc->add(Plucene::Document::Field->Text(message => $message->body));
360 + $doc->add(Plucene::Document::Field->Text(subject => $message->header("Subject")));
361 + $doc->add(Plucene::Document::Field->Text(author => $message->header("From")));
362 + my $t = Plucene::Document::DateSerializer::_to_base_36( str2time($message->header("Date"))*1000 );
363 + $doc->add(Plucene::Document::Field->Text(date => $t));
364 + $writer->add_document($doc);
365 + }
366 + }
367 +
368 + print "Finishing (this may take some time)..." if $opt{verbose};
369 + if ($Engine eq 'kinosearch' && $kinosearch_version eq 'old') {
370 + $writer->generate;
371 + $writer->write_kindex;
372 + } elsif ($Engine eq 'kinosearch' && $kinosearch_version eq 'new') {
373 + $writer->finish;
374 + } elsif ($Engine eq 'plucene') {
375 + $writer->optimize;
376 + }
377 + print "Done.\n" if $opt{verbose};
378 +
379 +
380 + open COUNTER, ">$list->{index_dir}/_ez_offset";
381 + print COUNTER $msg_id;
382 + close COUNTER;
383 +}
384 +END_TEXT
385 +}
386 +1;
387 diff -Nur --no-dereference smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/templates.metadata/opt/mailinglist/search/ez_indexer.pl smeserver-ezmlm-www-2.0.0/root/etc/e-smith/templates.metadata/opt/mailinglist/search/ez_indexer.pl
388 --- smeserver-ezmlm-www-2.0.0.old/root/etc/e-smith/templates.metadata/opt/mailinglist/search/ez_indexer.pl 1969-12-31 19:00:00.000000000 -0500
389 +++ smeserver-ezmlm-www-2.0.0/root/etc/e-smith/templates.metadata/opt/mailinglist/search/ez_indexer.pl 2022-03-18 23:27:43.740000000 -0400
390 @@ -0,0 +1 @@
391 +PERMS=0755

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed