[SOGo] Rename reconf-domains to bootstrap-sogo and exec sogod after a successful bootstrap; Wait for SOGo to die and free listener
parent
5d5646df0c
commit
b629089ff8
|
@ -17,6 +17,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
syslog-ng-core \
|
syslog-ng-core \
|
||||||
syslog-ng-mod-redis \
|
syslog-ng-mod-redis \
|
||||||
dirmngr \
|
dirmngr \
|
||||||
|
netcat \
|
||||||
|
psmisc \
|
||||||
wget \
|
wget \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
|
&& 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 \
|
&& echo '0 0 * * * sogo /usr/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds' >> /etc/cron.d/sogo \
|
||||||
&& touch /etc/default/locale
|
&& touch /etc/default/locale
|
||||||
|
|
||||||
COPY ./reconf-domains.sh /
|
COPY ./bootstrap-sogo.sh /
|
||||||
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
|
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
|
||||||
COPY supervisord.conf /etc/supervisor/supervisord.conf
|
COPY supervisord.conf /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
# Wait for MySQL to warm-up
|
# Wait for MySQL to warm-up
|
||||||
while mysqladmin ping --host 172.22.1.250 --silent; do
|
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
|
# Recreate view
|
||||||
|
|
||||||
mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "DROP VIEW IF EXISTS sogo_view"
|
mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "DROP VIEW IF EXISTS sogo_view"
|
||||||
|
@ -93,8 +100,6 @@ echo ' </dict>
|
||||||
chown sogo:sogo -R /var/lib/sogo/
|
chown sogo:sogo -R /var/lib/sogo/
|
||||||
chmod 600 /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
chmod 600 /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
||||||
|
|
||||||
supervisorctl restart sogo
|
exec gosu sogo /usr/sbin/sogod
|
||||||
|
|
||||||
sleep 99999
|
|
||||||
|
|
||||||
done
|
done
|
|
@ -22,8 +22,8 @@ user=sogo
|
||||||
autorestart=true
|
autorestart=true
|
||||||
priority=4
|
priority=4
|
||||||
|
|
||||||
[program:reconf-domains]
|
[program:bootstrap-sogo]
|
||||||
command=/reconf-domains.sh
|
command=/bootstrap-sogo.sh
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/stdout
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
|
@ -31,6 +31,7 @@ stderr_logfile_maxbytes=0
|
||||||
priority=3
|
priority=3
|
||||||
startretries=10
|
startretries=10
|
||||||
autorestart=true
|
autorestart=true
|
||||||
|
stopwaitsecs=120
|
||||||
|
|
||||||
[program:sogo]
|
[program:sogo]
|
||||||
command="/usr/sbin/sogod"
|
command="/usr/sbin/sogod"
|
||||||
|
|
|
@ -6,7 +6,7 @@ if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if ($_GET['ACTION'] == "start") {
|
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(
|
$context = stream_context_create(array('http' => array(
|
||||||
'method' => "POST",
|
'method' => "POST",
|
||||||
'header' => "Content-Length: " . strlen($request),
|
'header' => "Content-Length: " . strlen($request),
|
||||||
|
@ -22,7 +22,7 @@ if ($_GET['ACTION'] == "start") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($_GET['ACTION'] == "stop") {
|
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(
|
$context = stream_context_create(array('http' => array(
|
||||||
'method' => "POST",
|
'method' => "POST",
|
||||||
'header' => "Content-Length: " . strlen($request),
|
'header' => "Content-Length: " . strlen($request),
|
||||||
|
@ -34,21 +34,7 @@ elseif ($_GET['ACTION'] == "stop") {
|
||||||
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
|
echo '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
|
||||||
}
|
}
|
||||||
else {
|
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 '<b><span class="pull-right text-warning">' . $response['faultString'] . '</span></b>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo '<b><span class="pull-right text-success">OK</span></b>';
|
echo '<b><span class="pull-right text-success">OK</span></b>';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue