public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Dovecot] Remove master.pid if not running; Check for active imapsync besides lock file; Reconnect MySQL connection in imapsync_cron.pl
c7484434
data/Dockerfiles/dovecot/Dockerfile | 1 +
data/Dockerfiles/dovecot/docker-entrypoint.sh | 3 +++
data/Dockerfiles/dovecot/imapsync_cron.pl | 14 +++++++++++++-
3 files changed, 17 insertions(+), 1 deletion(-)
Diff
diff --git a/data/Dockerfiles/dovecot/Dockerfile b/data/Dockerfiles/dovecot/Dockerfile
index 33f64382..6148ed52 100644
--- a/data/Dockerfiles/dovecot/Dockerfile
+++ b/data/Dockerfiles/dovecot/Dockerfile
@@ -40,6 +40,7 @@ RUN apt-get update && apt-get -y install \
libtest-pod-perl \
libtest-simple-perl \
libunicode-string-perl \
+ libproc-processtable-perl \
liburi-perl \
lzma-dev \
make \
diff --git a/data/Dockerfiles/dovecot/docker-entrypoint.sh b/data/Dockerfiles/dovecot/docker-entrypoint.sh
index a07a3896..4e9fe14b 100755
--- a/data/Dockerfiles/dovecot/docker-entrypoint.sh
+++ b/data/Dockerfiles/dovecot/docker-entrypoint.sh
@@ -74,4 +74,7 @@ chown -R vmail:vmail /var/vmail/sieve
# Fix more than 1 hardlink issue
touch /etc/crontab /etc/cron.*/*
+# Clean old PID if any
+[[ -f /usr/local/var/run/dovecot/master.pid ]] && rm /usr/local/var/run/dovecot/master.pid
+
exec "$@"
diff --git a/data/Dockerfiles/dovecot/imapsync_cron.pl b/data/Dockerfiles/dovecot/imapsync_cron.pl
index 27419aac..26b5ad67 100755
--- a/data/Dockerfiles/dovecot/imapsync_cron.pl
+++ b/data/Dockerfiles/dovecot/imapsync_cron.pl
@@ -2,11 +2,20 @@
use DBI;
use LockFile::Simple qw(lock trylock unlock);
+use Proc::ProcessTable;
use Data::Dumper qw(Dumper);
use IPC::Run 'run';
use String::Util 'trim';
use File::Temp;
+my $t = Proc::ProcessTable->new;
+my $imapsync_running = grep { $_->{cmndline} =~ /^\/usr\/bin\/perl \/usr\/local\/bin\/imapsync\s/ } @{$t->table};
+if ($imapsync_running eq 1)
+{
+ print "imapsync is active, exiting...";
+ exit;
+}
+
$DBNAME = '';
$DBUSER = '';
$DBPASS = '';
@@ -16,7 +25,10 @@ $dsn = "DBI:mysql:database=" . $DBNAME . ";host=mysql";
$lock_file = $run_dir . "/imapsync_busy";
$lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1);
$lockmgr->lock($lock_file) || die "can't lock ${lock_file}";
-$dbh = DBI->connect($dsn, $DBUSER, $DBPASS);
+$dbh = DBI->connect($dsn, $DBUSER, $DBPASS, {
+ mysql_auto_reconnect => 1,
+ mysql_enable_utf8mb4 => 1
+});
open my $file, '<', "/etc/sogo/sieve.creds";
my $creds = <$file>;
close $file;