/[smecontribs]/rpms/smeserver-altqmail/contribs10/smeserver-altqmail-0.1.2-sme10-throttle.patch
ViewVC logotype

Annotation of /rpms/smeserver-altqmail/contribs10/smeserver-altqmail-0.1.2-sme10-throttle.patch

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


Revision 1.1 - (hide annotations) (download)
Fri Mar 24 03:45:27 2023 UTC (20 months ago) by jpp
Branch: MAIN
CVS Tags: smeserver-altqmail-0_1_2-2_el7_sme, HEAD
* Thu Mar 23 2023 Jean-Philippe Pialasse <tests@pialasse.com> 0.1.2-2.sme
- import to SME10 [SME: 12344]
  adapt for systemd and add update event
  add throttle capability

1 jpp 1.1 diff -Nur --no-dereference smeserver-altqmail-0.1.2.old/createlinks smeserver-altqmail-0.1.2/createlinks
2     --- smeserver-altqmail-0.1.2.old/createlinks 2017-11-19 04:53:47.000000000 -0500
3     +++ smeserver-altqmail-0.1.2/createlinks 2023-03-23 23:44:37.531000000 -0400
4     @@ -2,28 +2,55 @@
5    
6     use esmith::Build::CreateLinks qw(:all);
7    
8     -service_link_enhanced("altqmail", "S80", "7");
9     -service_link_enhanced("altqmail", "K60", "6");
10     -service_link_enhanced("altqmail", "K60", "0");
11     -service_link_enhanced("altqmail", "K60", "1");
12     -service_link_enhanced("altqmail-smtpd", "S80", "7");
13     -service_link_enhanced("altqmail-smtpd", "K60", "6");
14     -service_link_enhanced("altqmail-smtpd", "K60", "0");
15     -service_link_enhanced("altqmail-smtpd", "K60", "1");
16     +#service_link_enhanced("altqmail", "S80", "7");
17     +#service_link_enhanced("altqmail", "K60", "6");
18     +#service_link_enhanced("altqmail", "K60", "0");
19     +#service_link_enhanced("altqmail", "K60", "1");
20     +#service_link_enhanced("altqmail-smtpd", "S80", "7");
21     +#service_link_enhanced("altqmail-smtpd", "K60", "6");
22     +#service_link_enhanced("altqmail-smtpd", "K60", "0");
23     +#service_link_enhanced("altqmail-smtpd", "K60", "1");
24    
25     safe_touch("root/var/service/altqmail/down");
26     safe_touch("root/var/service/altqmail-smtpd/down");
27     -safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/altqmail');
28     -safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/altqmail-smtpd');
29     +#safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/altqmail');
30     +#safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/altqmail-smtpd');
31    
32     safe_symlink("/var/service/altqmail" , 'root/service/altqmail');
33     safe_symlink("/var/service/altqmail-smtpd" , 'root/service/altqmail-smtpd');
34    
35     -safe_symlink("sighup", "root/etc/e-smith/events/email-update/services2adjust/altqmail");
36     -safe_symlink("sighup", "root/etc/e-smith/events/email-update/services2adjust/altqmail-smtpd");
37     +safe_symlink("reload-or-restart", "root/etc/e-smith/events/email-update/services2adjust/altqmail");
38     +safe_symlink("reload-or-restart", "root/etc/e-smith/events/email-update/services2adjust/altqmail-smtpd");
39    
40     -foreach my $f (qw(me bouncehost smtproutes concurrencyremote)){
41     +foreach my $f (qw(me bouncehost smtproutes concurrencyremote outratelimit)){
42     safe_touch("root/etc/e-smith/templates/var/service/altqmail/root/var/qmail/control/$f/template-begin");
43     templates2events("/var/service/altqmail/root/var/qmail/control/$f", qw(email-update bootstrap-console-save));
44     }
45    
46     +my $pkg= "smeserver-altqmail";
47     +my $event = "${pkg}-update";
48     +
49     +event_actions($event, qw(
50     + systemd-default 88
51     + systemd-reload 89
52     +));
53     +
54     +event_templates($event, qw(
55     +/var/service/altqmail/root/var/qmail/control/me
56     +/var/service/altqmail/root/var/qmail/control/bouncehost
57     +/var/service/altqmail/root/var/qmail/control/smtproutes
58     +/var/service/altqmail/root/var/qmail/control/concurrencyremote
59     +/var/service/altqmail/root/var/qmail/control/outratelimit
60     +));
61     +
62     +event_services($event, qw(
63     + altqmail reload-or-restart
64     + altqmail-smtpd reload-or-restart
65     + qmail restart
66     +));
67     +
68     +#nothing to backup restore
69     +#use esmith::Build::Backup qw(:all);
70     +#backup_includes($pkg, qw(
71     +#/opt/foo/
72     +#));
73     diff -Nur --no-dereference smeserver-altqmail-0.1.2.old/root/etc/e-smith/templates/var/service/altqmail/root/var/qmail/control/outratelimit/10all smeserver-altqmail-0.1.2/root/etc/e-smith/templates/var/service/altqmail/root/var/qmail/control/outratelimit/10all
74     --- smeserver-altqmail-0.1.2.old/root/etc/e-smith/templates/var/service/altqmail/root/var/qmail/control/outratelimit/10all 1969-12-31 19:00:00.000000000 -0500
75     +++ smeserver-altqmail-0.1.2/root/etc/e-smith/templates/var/service/altqmail/root/var/qmail/control/outratelimit/10all 2023-03-23 23:29:13.227000000 -0400
76     @@ -0,0 +1 @@
77     +{ $DB->get('altqmail')->prop('OutRateLimit') || "20/3600"; }
78     diff -Nur --no-dereference smeserver-altqmail-0.1.2.old/root/usr/lib/systemd/system/altqmail.service smeserver-altqmail-0.1.2/root/usr/lib/systemd/system/altqmail.service
79     --- smeserver-altqmail-0.1.2.old/root/usr/lib/systemd/system/altqmail.service 1969-12-31 19:00:00.000000000 -0500
80     +++ smeserver-altqmail-0.1.2/root/usr/lib/systemd/system/altqmail.service 2023-03-23 22:10:48.539000000 -0400
81     @@ -0,0 +1,16 @@
82     +[Unit]
83     +Description=altqmail, message transfer agent
84     +After=network.target
85     +Requires=runit.service
86     +
87     +[Service]
88     +Type=oneshot
89     +ExecStartPre=/sbin/e-smith/service-status altqmail
90     +ExecStart=/usr/bin/sv u /service/altqmail
91     +ExecStop=/usr/bin/sv stop /service/altqmail
92     +ExecReload=/usr/bin/sv t /service/altqmail
93     +RemainAfterExit=yes
94     +
95     +[Install]
96     +WantedBy=sme-server.target
97     +
98     diff -Nur --no-dereference smeserver-altqmail-0.1.2.old/root/usr/lib/systemd/system/altqmail-smtpd.service smeserver-altqmail-0.1.2/root/usr/lib/systemd/system/altqmail-smtpd.service
99     --- smeserver-altqmail-0.1.2.old/root/usr/lib/systemd/system/altqmail-smtpd.service 1969-12-31 19:00:00.000000000 -0500
100     +++ smeserver-altqmail-0.1.2/root/usr/lib/systemd/system/altqmail-smtpd.service 2023-03-23 22:19:27.855000000 -0400
101     @@ -0,0 +1,16 @@
102     +[Unit]
103     +Description=altqmail-smtpd, message transfer agent
104     +After=network.target
105     +Requires=runit.service
106     +
107     +[Service]
108     +Type=oneshot
109     +ExecStartPre=/sbin/e-smith/service-status altqmail-smtpd
110     +ExecStart=/usr/bin/sv u /service/altqmail-smtpd
111     +ExecStop=/usr/bin/sv stop /service/altqmail-smtpd
112     +ExecReload=/usr/bin/sv t /service/altqmail-smtpd
113     +RemainAfterExit=yes
114     +
115     +[Install]
116     +WantedBy=sme-server.target
117     +
118     diff -Nur --no-dereference smeserver-altqmail-0.1.2.old/root/var/service/altqmail/finish smeserver-altqmail-0.1.2/root/var/service/altqmail/finish
119     --- smeserver-altqmail-0.1.2.old/root/var/service/altqmail/finish 2017-11-19 04:53:47.000000000 -0500
120     +++ smeserver-altqmail-0.1.2/root/var/service/altqmail/finish 2023-03-23 23:19:04.622000000 -0400
121     @@ -1,5 +1,6 @@
122     #!/bin/sh
123    
124     -umount /var/service/altqmail/root/var/qmail/bin
125     +#umount /var/service/altqmail/root/var/qmail/bin
126     +rm -rf /var/service/altqmail/root/var/qmail/bin/*
127     rm -rf root/etc
128     rm -rf root/lib{,64}
129     diff -Nur --no-dereference smeserver-altqmail-0.1.2.old/root/var/service/altqmail/qmail-remote-throttle smeserver-altqmail-0.1.2/root/var/service/altqmail/qmail-remote-throttle
130     --- smeserver-altqmail-0.1.2.old/root/var/service/altqmail/qmail-remote-throttle 1969-12-31 19:00:00.000000000 -0500
131     +++ smeserver-altqmail-0.1.2/root/var/service/altqmail/qmail-remote-throttle 2023-03-23 23:33:43.608000000 -0400
132     @@ -0,0 +1,119 @@
133     +#!/usr/bin/perl
134     +
135     +use Fcntl ':flock';
136     +$QMAIL = "/var/qmail";
137     +$CONTROL = "$QMAIL/control";
138     +
139     +open LOG, ">>", "/tmp/qmail-remote-log";
140     +{ my $ofh = select LOG; $|=1; select $ofh; }
141     +Log("starting");
142     +
143     +$msgs = 0;
144     +$time = 0;
145     +
146     +load_policy();
147     +
148     +
149     +while(1) {
150     + my @last = grep {$_ > time() - $time} read_log();
151     + Log("status " . @last . "/$msgs");
152     +
153     + if (@last >= $msgs) {
154     +# Log("sleeping");
155     + } else {
156     + last;
157     + }
158     +
159     + while (@last >= $msgs) {
160     + my $oldest = $last[0];
161     + my $age = time() - $oldest;
162     + # When will the oldest message expire off the queue?
163     + # The end of the queue is $time seconds ago
164     + # The age of the oldest message is now time() - $oldest
165     + # The oldest message will expire in $time - $age seconds
166     + my $zzz = $time - $age + int(rand(3));
167     + $zzz = 1 if $zzz < 1;
168     +# Log("Sleeping for $zzz secs");
169     + sleep $zzz;
170     + shift @last while @last && $last[0] < time() - $time;
171     + load_policy();
172     + }
173     +}
174     +
175     +append_log(time());
176     +
177     +#if (open F, ">>", "/tmp/qmail-remote-log") {
178     +# print F time(), " @ARGV\n";
179     +#}
180     +Log("sending @ARGV");
181     +exec "/var/qmail/bin/qmail-remote.real", @ARGV;
182     +exit 0;
183     +
184     +
185     +sub fail {
186     + my $msg = shift;
187     + Log("fail: $msg");
188     + print "Z$msg";
189     + exit 0;
190     +}
191     +
192     +my $last_policy_load ;
193     +sub load_policy {
194     + my $POLICY = "$CONTROL/outratelimit";
195     + return if ((stat($POLICY))[9] <= $last_policy_load);
196     + if (open F, "<", $POLICY) {
197     + chomp(my $line = <F>);
198     + ($msgs, $time) = split m{/}, $line;
199     + if (defined $last_policy_load) {
200     + Log("Policy changed to $msgs/$time");
201     + }
202     + $last_policy_load = time();
203     + close F;
204     + }
205     +}
206     +
207     +
208     +sub read_log {
209     + lock_semaphore(LOCK_SH);
210     +
211     + my @last;
212     + if (open(F, "+<", "$CONTROL/outlog")) {
213     + chomp(@last = <F>);
214     + close F;
215     + }
216     +
217     + lock_semaphore(LOCK_UN);
218     +
219     + return @last;
220     +}
221     +
222     +sub append_log {
223     + lock_semaphore(LOCK_EX);
224     +
225     + if (open(F, "+<", "$CONTROL/outlog")) {
226     + my @last = grep {$_ > time() - $time} <F>;
227     + chomp(@last);
228     + truncate F, 0;
229     + seek F, 0, 0;
230     + print F join "\n", @last, @_, "";
231     + close F;
232     + }
233     +
234     + lock_semaphore(LOCK_UN);
235     +}
236     +
237     +
238     +sub lock_semaphore {
239     + if (open SEM, ">", "$CONTROL/qmail-remote-semaphore") {
240     + flock(SEM, $_[0]) or fail("Couldn't lock semaphore: $!");
241     + } else {
242     + fail("Couldn't open semaphore: $!");
243     + }
244     +}
245     +
246     +sub Log {
247     + my @args = @_;
248     + tr/\n//d for @args;
249     + print LOG time(), " $$ @args\n";
250     +}
251     +
252     diff -Nur --no-dereference smeserver-altqmail-0.1.2.old/root/var/service/altqmail/run smeserver-altqmail-0.1.2/root/var/service/altqmail/run
253     --- smeserver-altqmail-0.1.2.old/root/var/service/altqmail/run 2017-11-19 04:53:47.000000000 -0500
254     +++ smeserver-altqmail-0.1.2/root/var/service/altqmail/run 2023-03-23 23:18:46.569000000 -0400
255     @@ -2,7 +2,13 @@
256    
257     exec 2>&1
258    
259     -/bin/mount --bind /var/qmail/bin/ root/var/qmail/bin
260     +#/bin/mount --bind /var/qmail/bin/ root/var/qmail/bin
261     +if [ ! -f root/var/qmail/bin/ ]; then
262     + cp -a /var/qmail/bin/* root/var/qmail/bin/
263     + mv root/var/qmail/bin/qmail-remote root/var/qmail/bin/qmail-remote.real
264     + cp -a qmail-remote-throttle root/var/qmail/bin/qmail-remote
265     +
266     +fi
267    
268     if [ ! -d root/etc ]; then
269     mkdir root/etc
270     @@ -13,13 +19,10 @@
271     fi
272    
273     LIBDIR="lib"
274     -LIBC="2.5"
275     +LIBC="2.17"
276     if [ -d /lib64 ]; then
277     LIBDIR="lib64"
278     fi
279     -if [ -e /$LIBDIR/libc-2.12.so ]; then
280     - LIBC="2.12"
281     -fi
282    
283     if [ ! -d root/$LIBDIR ]; then
284     mkdir root/$LIBDIR
285     @@ -35,6 +38,66 @@
286     ln -s libnss_files-$LIBC.so root/$LIBDIR/libnss_files.so.2
287     cp -a /$LIBDIR/libresolv-$LIBC.so root/$LIBDIR
288     ln -s libresolv-$LIBC.so root/$LIBDIR/libresolv.so.2
289     +
290     + ## added for throttle
291     + # for perl /usr/bin/perl
292     + #cp --parents `ldd BIN_PATH | cut -d " " -f 3` CHROOT_PATH
293     + #cp -a --parents `ldd /usr/bin/perl | cut -d " " -f 3` root/
294     + # wold almost work inside a loop checking if link and cpying also the target
295     + cp -a --parents /usr/$LIBDIR/perl5/CORE/libperl.so root/
296     + cp -a --parents /$LIBDIR/libresolv.so.2 root/
297     + cp -a --parents /$LIBDIR/libnsl.so.1 root/
298     + cp -a --parents /$LIBDIR/libnsl-$LIBC.so root/
299     + cp -a --parents /$LIBDIR/libdl.so.2 root/
300     + cp -a --parents /$LIBDIR/libdl-$LIBC.so root/
301     + cp -a --parents /$LIBDIR/libm.so.6 root/
302     + cp -a --parents /$LIBDIR/libm-$LIBC.so root/
303     + cp -a --parents /$LIBDIR/libcrypt.so.1 root/
304     + cp -a --parents /$LIBDIR/libcrypt-$LIBC.so root/
305     + cp -a --parents /$LIBDIR/libutil.so.1 root/
306     + cp -a --parents /$LIBDIR/libutil-$LIBC.so root/
307     + cp -a --parents /$LIBDIR/libpthread.so.0 root/
308     + cp -a --parents /$LIBDIR/libpthread-$LIBC.so root/
309     + cp -a --parents /lib64/libfreebl3.so root/
310     +
311     + cp -a --parents /usr/$LIBDIR/perl5/Fcntl.pm root/
312     + cp -a --parents /usr/$LIBDIR/perl5/auto/Fcntl root/
313     + cp -a --parents /usr/share/perl5/strict.pm root/
314     + cp -a --parents /usr/share/perl5/AutoLoader.pm root/
315     + cp -a --parents /usr/share/perl5/Carp.pm root/
316     + cp -a --parents /usr/share/perl5/Carp/Heavy.pm root/
317     + cp -a --parents /usr/share/perl5/Exporter.pm root/
318     + cp -a --parents /usr/share/perl5/Exporter root/
319     + cp -a --parents /usr/share/perl5/warnings.pm root/
320     +
321     + cp -a --parents /usr/$LIBDIR/perl5/XSLoader.pm root/
322     + cp -a --parents /usr/$LIBDIR/perl5/DynaLoader.pm root/
323     + cp -a --parents /usr/$LIBDIR/perl5/Config.pm root/
324     + cp -a --parents /usr/$LIBDIR/perl5/Config_heavy.pl root/
325     + cp -a --parents /usr/$LIBDIR/perl5/Config_git.pl root/
326     + cp -a --parents /usr/$LIBDIR/perl5/auto/DynaLoader/dl_findfile.al root/
327     +
328     + # might better somewhere else
329     + cp -a --parents /usr/bin/perl root/
330     + # this one is needed to set locale for perl
331     + cp -a --parent /usr/lib/locale root/
332     +
333     + #bin sh for qmail-qstat
334     + cp -a --parents /bin/sh root/
335     + cp -a --parents /bin/bash root/
336     + cp -a --parents /$LIBDIR/libtinfo.so.5 root/
337     + cp -a --parents /$LIBDIR/libtinfo.so.5.7 root/
338     +
339     + cp -a --parents /usr/bin/wc root/
340     + cp -a --parents /bin/find root/
341     + cp -a --parents /usr/bin/expr root/
342     + cp -a --parents /$LIBDIR/libselinux.so.1 root/
343     + cp -a --parents /$LIBDIR/librt.so.1 root/
344     + cp -a --parents /$LIBDIR/librt-2.12.so root/
345     + cp -a --parents /usr/$LIBDIR/libgmp.so.3 root/
346     + cp -a --parents /usr/$LIBDIR/libgmp.so.3.5.0 root/
347     +
348     +
349     fi
350    
351     chown qmails:qmail root/var/qmail/queue/lock/trigger

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