[Dovecot] Update imapsync - thanks to @hunter-nl
commit
2b6e486a11
|
@ -12,68 +12,76 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
|
||||||
build-essential \
|
build-essential \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
cpanminus \
|
cpanminus \
|
||||||
|
cron \
|
||||||
curl \
|
curl \
|
||||||
default-libmysqlclient-dev \
|
default-libmysqlclient-dev \
|
||||||
dnsutils \
|
dnsutils \
|
||||||
gettext \
|
gettext \
|
||||||
jq \
|
jq \
|
||||||
libjson-webtoken-perl \
|
|
||||||
libcgi-pm-perl \
|
|
||||||
libcrypt-openssl-rsa-perl \
|
|
||||||
libdata-uniqid-perl \
|
|
||||||
libhtml-parser-perl \
|
|
||||||
libmail-imapclient-perl \
|
|
||||||
libparse-recdescent-perl \
|
|
||||||
libsys-meminfo-perl \
|
|
||||||
libtest-mockobject-perl \
|
|
||||||
libwww-perl \
|
|
||||||
libauthen-ntlm-perl \
|
libauthen-ntlm-perl \
|
||||||
libbz2-dev \
|
libbz2-dev \
|
||||||
|
libcgi-pm-perl \
|
||||||
|
libcrypt-openssl-rsa-perl \
|
||||||
libcrypt-ssleay-perl \
|
libcrypt-ssleay-perl \
|
||||||
libcurl4-openssl-dev \
|
libcurl4-openssl-dev \
|
||||||
|
libdata-uniqid-perl \
|
||||||
libdbd-mysql-perl \
|
libdbd-mysql-perl \
|
||||||
libdbi-perl \
|
libdbi-perl \
|
||||||
libdigest-hmac-perl \
|
libdigest-hmac-perl \
|
||||||
|
libdist-checkconflicts-perl \
|
||||||
libexpat1-dev \
|
libexpat1-dev \
|
||||||
libfile-copy-recursive-perl \
|
libfile-copy-recursive-perl \
|
||||||
|
libfile-tail-perl \
|
||||||
|
libhtml-parser-perl \
|
||||||
libio-compress-perl \
|
libio-compress-perl \
|
||||||
libio-socket-inet6-perl \
|
libio-socket-inet6-perl \
|
||||||
libio-socket-ssl-perl \
|
libio-socket-ssl-perl \
|
||||||
libio-tee-perl \
|
libio-tee-perl \
|
||||||
libipc-run-perl \
|
libipc-run-perl \
|
||||||
|
libjson-webtoken-perl \
|
||||||
libldap2-dev \
|
libldap2-dev \
|
||||||
liblockfile-simple-perl \
|
liblockfile-simple-perl \
|
||||||
liblz-dev \
|
liblz-dev \
|
||||||
liblz4-dev \
|
liblz4-dev \
|
||||||
liblzma-dev \
|
liblzma-dev \
|
||||||
|
libmail-imapclient-perl \
|
||||||
|
libmodule-implementation-perl \
|
||||||
libmodule-scandeps-perl \
|
libmodule-scandeps-perl \
|
||||||
libnet-ssleay-perl \
|
libnet-ssleay-perl \
|
||||||
|
libpackage-stash-perl \
|
||||||
|
libpackage-stash-xs-perl \
|
||||||
libpam-dev \
|
libpam-dev \
|
||||||
libpar-packer-perl \
|
libpar-packer-perl \
|
||||||
|
libparse-recdescent-perl \
|
||||||
|
libproc-processtable-perl \
|
||||||
libreadonly-perl \
|
libreadonly-perl \
|
||||||
|
libregexp-common-perl \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
|
libsys-meminfo-perl \
|
||||||
libterm-readkey-perl \
|
libterm-readkey-perl \
|
||||||
|
libtest-deep-perl \
|
||||||
|
libtest-fatal-perl \
|
||||||
|
libtest-mock-guard-perl \
|
||||||
|
libtest-mockobject-perl \
|
||||||
|
libtest-nowarnings-perl \
|
||||||
libtest-pod-perl \
|
libtest-pod-perl \
|
||||||
|
libtest-requires-perl \
|
||||||
libtest-simple-perl \
|
libtest-simple-perl \
|
||||||
|
libtest-warn-perl \
|
||||||
libtry-tiny-perl \
|
libtry-tiny-perl \
|
||||||
libunicode-string-perl \
|
libunicode-string-perl \
|
||||||
libproc-processtable-perl \
|
|
||||||
libtest-nowarnings-perl \
|
|
||||||
libtest-deep-perl \
|
|
||||||
libtest-warn-perl \
|
|
||||||
libregexp-common-perl \
|
|
||||||
liburi-perl \
|
liburi-perl \
|
||||||
|
libwww-perl \
|
||||||
lzma-dev \
|
lzma-dev \
|
||||||
|
make \
|
||||||
|
mysql-client \
|
||||||
|
procps \
|
||||||
python-html2text \
|
python-html2text \
|
||||||
python-jinja2 \
|
python-jinja2 \
|
||||||
python-mysql.connector \
|
python-mysql.connector \
|
||||||
python-redis \
|
python-redis \
|
||||||
make \
|
|
||||||
mysql-client \
|
|
||||||
procps \
|
|
||||||
supervisor \
|
|
||||||
cron \
|
|
||||||
redis-server \
|
redis-server \
|
||||||
|
supervisor \
|
||||||
syslog-ng \
|
syslog-ng \
|
||||||
syslog-ng-core \
|
syslog-ng-core \
|
||||||
syslog-ng-mod-redis \
|
syslog-ng-mod-redis \
|
||||||
|
@ -93,7 +101,6 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
|
||||||
&& make clean \
|
&& make clean \
|
||||||
&& cd .. \
|
&& cd .. \
|
||||||
&& rm -rf dovecot-2.3-pigeonhole-$PIGEONHOLE_VERSION \
|
&& rm -rf dovecot-2.3-pigeonhole-$PIGEONHOLE_VERSION \
|
||||||
&& cpanm Data::Uniqid Mail::IMAPClient String::Util \
|
|
||||||
&& groupadd -g 5000 vmail \
|
&& groupadd -g 5000 vmail \
|
||||||
&& groupadd -g 401 dovecot \
|
&& groupadd -g 401 dovecot \
|
||||||
&& groupadd -g 402 dovenull \
|
&& groupadd -g 402 dovenull \
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,11 +5,11 @@ use LockFile::Simple qw(lock trylock unlock);
|
||||||
use Proc::ProcessTable;
|
use Proc::ProcessTable;
|
||||||
use Data::Dumper qw(Dumper);
|
use Data::Dumper qw(Dumper);
|
||||||
use IPC::Run 'run';
|
use IPC::Run 'run';
|
||||||
use String::Util 'trim';
|
|
||||||
use File::Temp;
|
use File::Temp;
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
use sigtrap 'handler' => \&sig_handler, qw(INT TERM KILL QUIT);
|
use sigtrap 'handler' => \&sig_handler, qw(INT TERM KILL QUIT);
|
||||||
|
|
||||||
|
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
|
||||||
my $t = Proc::ProcessTable->new;
|
my $t = Proc::ProcessTable->new;
|
||||||
my $imapsync_running = grep { $_->{cmndline} =~ /^\/usr\/bin\/perl \/usr\/local\/bin\/imapsync\s/ } @{$t->table};
|
my $imapsync_running = grep { $_->{cmndline} =~ /^\/usr\/bin\/perl \/usr\/local\/bin\/imapsync\s/ } @{$t->table};
|
||||||
if ($imapsync_running eq 1)
|
if ($imapsync_running eq 1)
|
||||||
|
@ -19,11 +19,20 @@ if ($imapsync_running eq 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub qqw($) {
|
sub qqw($) {
|
||||||
my @values = split('(?=--)', $_[0]);
|
my @params = ();
|
||||||
|
my @values = split(/(?=--)/, $_[0]);
|
||||||
foreach my $val (@values) {
|
foreach my $val (@values) {
|
||||||
|
my @tmpparam = split(/ /, $val, 2);
|
||||||
|
foreach my $tmpval (@tmpparam) {
|
||||||
|
if ($tmpval ne '') {
|
||||||
|
push @params, $tmpval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach my $val (@params) {
|
||||||
$val=trim($val);
|
$val=trim($val);
|
||||||
}
|
}
|
||||||
return @values
|
return @params;
|
||||||
}
|
}
|
||||||
|
|
||||||
$run_dir="/tmp";
|
$run_dir="/tmp";
|
||||||
|
@ -101,10 +110,6 @@ while ($row = $sth->fetchrow_arrayref()) {
|
||||||
$timeout1 = @$row[19];
|
$timeout1 = @$row[19];
|
||||||
$timeout2 = @$row[20];
|
$timeout2 = @$row[20];
|
||||||
|
|
||||||
$is_running = $dbh->prepare("UPDATE imapsync SET is_running = 1 WHERE id = ?");
|
|
||||||
$is_running->bind_param( 1, ${id} );
|
|
||||||
$is_running->execute();
|
|
||||||
|
|
||||||
if ($enc1 eq "TLS") { $enc1 = "--tls1"; } elsif ($enc1 eq "SSL") { $enc1 = "--ssl1"; } else { undef $enc1; }
|
if ($enc1 eq "TLS") { $enc1 = "--tls1"; } elsif ($enc1 eq "SSL") { $enc1 = "--ssl1"; } else { undef $enc1; }
|
||||||
|
|
||||||
my $template = $run_dir . '/imapsync.XXXXXXX';
|
my $template = $run_dir . '/imapsync.XXXXXXX';
|
||||||
|
@ -140,21 +145,31 @@ while ($row = $sth->fetchrow_arrayref()) {
|
||||||
"--host2", "localhost",
|
"--host2", "localhost",
|
||||||
"--user2", $user2 . '*' . trim($master_user),
|
"--user2", $user2 . '*' . trim($master_user),
|
||||||
"--passfile2", $passfile2->filename,
|
"--passfile2", $passfile2->filename,
|
||||||
'--no-modulesversion'];
|
'--no-modulesversion',
|
||||||
|
'--noreleasecheck'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$is_running = $dbh->prepare("UPDATE imapsync SET is_running = 1 WHERE id = ?");
|
||||||
|
$is_running->bind_param( 1, ${id} );
|
||||||
|
$is_running->execute();
|
||||||
|
|
||||||
run [@$generated_cmds, @$custom_params_ref], '&>', \my $stdout;
|
run [@$generated_cmds, @$custom_params_ref], '&>', \my $stdout;
|
||||||
$update = $dbh->prepare("UPDATE imapsync SET returned_text = ?, last_run = NOW(), is_running = 0 WHERE id = ?");
|
|
||||||
|
$update = $dbh->prepare("UPDATE imapsync SET returned_text = ? WHERE id = ?");
|
||||||
$update->bind_param( 1, ${stdout} );
|
$update->bind_param( 1, ${stdout} );
|
||||||
$update->bind_param( 2, ${id} );
|
$update->bind_param( 2, ${id} );
|
||||||
$update->execute();
|
$update->execute();
|
||||||
} catch {
|
} catch {
|
||||||
$update = $dbh->prepare("UPDATE imapsync SET returned_text = 'Could not start or finish imapsync', last_run = NOW(), is_running = 0 WHERE id = ?");
|
$update = $dbh->prepare("UPDATE imapsync SET returned_text = 'Could not start or finish imapsync' WHERE id = ?");
|
||||||
|
$update->bind_param( 1, ${id} );
|
||||||
|
$update->execute();
|
||||||
|
} finally {
|
||||||
|
$update = $dbh->prepare("UPDATE imapsync SET last_run = NOW(), is_running = 0 WHERE id = ?");
|
||||||
$update->bind_param( 1, ${id} );
|
$update->bind_param( 1, ${id} );
|
||||||
$update->execute();
|
$update->execute();
|
||||||
$lockmgr->unlock($lock_file);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
|
|
Loading…
Reference in New Issue