diff --git a/data/Dockerfiles/sogo/Dockerfile b/data/Dockerfiles/sogo/Dockerfile
index 0fc4675f..a9cefc47 100644
--- a/data/Dockerfiles/sogo/Dockerfile
+++ b/data/Dockerfiles/sogo/Dockerfile
@@ -17,6 +17,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
syslog-ng-core \
syslog-ng-mod-redis \
dirmngr \
+ netcat \
+ psmisc \
wget \
&& rm -rf /var/lib/apt/lists/* \
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
@@ -37,7 +39,7 @@ RUN mkdir /usr/share/doc/sogo \
&& echo '0 0 * * * sogo /usr/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds' >> /etc/cron.d/sogo \
&& touch /etc/default/locale
-COPY ./reconf-domains.sh /
+COPY ./bootstrap-sogo.sh /
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
COPY supervisord.conf /etc/supervisor/supervisord.conf
diff --git a/data/Dockerfiles/sogo/reconf-domains.sh b/data/Dockerfiles/sogo/bootstrap-sogo.sh
similarity index 96%
rename from data/Dockerfiles/sogo/reconf-domains.sh
rename to data/Dockerfiles/sogo/bootstrap-sogo.sh
index ec0d4c93..92acb591 100755
--- a/data/Dockerfiles/sogo/reconf-domains.sh
+++ b/data/Dockerfiles/sogo/bootstrap-sogo.sh
@@ -3,6 +3,13 @@
# Wait for MySQL to warm-up
while mysqladmin ping --host 172.22.1.250 --silent; do
+# Wait until port becomes free and send sig
+until ! nc -z sogo-mailcow 20000;
+do
+ killall -TERM sogod
+ sleep 3
+done
+
# Recreate view
mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "DROP VIEW IF EXISTS sogo_view"
@@ -93,8 +100,6 @@ echo '
chown sogo:sogo -R /var/lib/sogo/
chmod 600 /var/lib/sogo/GNUstep/Defaults/sogod.plist
-supervisorctl restart sogo
-
-sleep 99999
+exec gosu sogo /usr/sbin/sogod
done
diff --git a/data/Dockerfiles/sogo/supervisord.conf b/data/Dockerfiles/sogo/supervisord.conf
index 7b77d15d..06eb4985 100644
--- a/data/Dockerfiles/sogo/supervisord.conf
+++ b/data/Dockerfiles/sogo/supervisord.conf
@@ -22,8 +22,8 @@ user=sogo
autorestart=true
priority=4
-[program:reconf-domains]
-command=/reconf-domains.sh
+[program:bootstrap-sogo]
+command=/bootstrap-sogo.sh
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
@@ -31,6 +31,7 @@ stderr_logfile_maxbytes=0
priority=3
startretries=10
autorestart=true
+stopwaitsecs=120
[program:sogo]
command="/usr/sbin/sogod"
diff --git a/data/web/inc/call_sogo_ctrl.php b/data/web/inc/call_sogo_ctrl.php
index 7c7cff9e..990defa2 100644
--- a/data/web/inc/call_sogo_ctrl.php
+++ b/data/web/inc/call_sogo_ctrl.php
@@ -6,7 +6,7 @@ if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role
exit();
}
if ($_GET['ACTION'] == "start") {
- $request = xmlrpc_encode_request("supervisor.startProcess", 'reconf-domains', array('encoding'=>'utf-8'));
+ $request = xmlrpc_encode_request("supervisor.startProcess", 'bootstrap-sogo', array('encoding'=>'utf-8'));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Length: " . strlen($request),
@@ -22,7 +22,7 @@ if ($_GET['ACTION'] == "start") {
}
}
elseif ($_GET['ACTION'] == "stop") {
- $request = xmlrpc_encode_request("supervisor.stopProcess", 'sogo', array('encoding'=>'utf-8'));
+ $request = xmlrpc_encode_request("supervisor.stopProcess", 'bootstrap-sogo', array('encoding'=>'utf-8'));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Length: " . strlen($request),
@@ -34,21 +34,7 @@ elseif ($_GET['ACTION'] == "stop") {
echo '' . $response['faultString'] . '';
}
else {
- sleep(4);
- $request = xmlrpc_encode_request("supervisor.stopProcess", 'reconf-domains', array('encoding'=>'utf-8'));
- $context = stream_context_create(array('http' => array(
- 'method' => "POST",
- 'header' => "Content-Length: " . strlen($request),
- 'content' => $request
- )));
- $file = @file_get_contents("http://sogo:9191/RPC2", false, $context) or die("Cannot connect to $remote_server:$listener_port");
- $response = xmlrpc_decode($file);
- if (isset($response['faultString'])) {
- echo '' . $response['faultString'] . '';
- }
- else {
echo 'OK';
- }
}
}
-?>
\ No newline at end of file
+?>