Restart SOGo from within panel
parent
301bd3bc9f
commit
f7b95ae5a0
|
@ -4,10 +4,10 @@ MAINTAINER Andre Peters <andre.peters@servercow.de>
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y zlib1g-dev libicu-dev g++ libidn11-dev
|
&& apt-get install -y zlib1g-dev libicu-dev g++ libidn11-dev libxml2-dev
|
||||||
|
|
||||||
RUN docker-php-ext-configure intl
|
RUN docker-php-ext-configure intl
|
||||||
RUN docker-php-ext-install intl pdo pdo_mysql
|
RUN docker-php-ext-install intl pdo pdo_mysql xmlrpc
|
||||||
|
|
||||||
COPY ./docker-entrypoint.sh /
|
COPY ./docker-entrypoint.sh /
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,12 @@ RUN echo '* * * * * sogo /usr/sbin/sogo-ealarms-notify' > /etc/cron.d/sogo
|
||||||
RUN echo '* * * * * sogo /usr/sbin/sogo-tool expire-sessions 60' >> /etc/cron.d/sogo
|
RUN echo '* * * * * sogo /usr/sbin/sogo-tool expire-sessions 60' >> /etc/cron.d/sogo
|
||||||
RUN echo '0 0 * * * sogo /usr/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds' >> /etc/cron.d/sogo
|
RUN echo '0 0 * * * sogo /usr/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds' >> /etc/cron.d/sogo
|
||||||
|
|
||||||
COPY ./docker-entrypoint.sh /
|
COPY ./reconf-domains.sh /
|
||||||
COPY supervisord.conf /etc/supervisor/supervisord.conf
|
COPY supervisord.conf /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
EXPOSE 20000
|
EXPOSE 20000
|
||||||
|
EXPOSE 9191
|
||||||
|
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
|
||||||
CMD exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
CMD exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Wait for MySQL to warm-up
|
# Go in a 5 minute loop
|
||||||
while ! mysqladmin ping --host mysql --silent; do
|
while true; do
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
mkdir -p /var/lib/sogo/GNUstep/Defaults/
|
# Wait for MySQL to warm-up
|
||||||
|
while ! mysqladmin ping --host mysql --silent; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
# Generate plist header with timezone data
|
mkdir -p /var/lib/sogo/GNUstep/Defaults/
|
||||||
cat <<EOF > /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
|
||||||
|
# Generate plist header with timezone data
|
||||||
|
cat <<EOF > /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//GNUstep//DTD plist 0.9//EN" "http://www.gnustep.org/plist-0_9.xml">
|
<!DOCTYPE plist PUBLIC "-//GNUstep//DTD plist 0.9//EN" "http://www.gnustep.org/plist-0_9.xml">
|
||||||
<plist version="0.9">
|
<plist version="0.9">
|
||||||
|
@ -33,11 +36,11 @@ cat <<EOF > /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
||||||
<dict>
|
<dict>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Generate multi-domain setup
|
# Generate multi-domain setup
|
||||||
while read line
|
while read line
|
||||||
do
|
do
|
||||||
DOMAIN_SANE=$(echo ${line} | tr '-' 'b' | tr '.' 'p' | tr -cd '[[:alnum:]]')
|
DOMAIN_SANE=$(echo ${line} | tr '-' 'b' | tr '.' 'p' | tr -cd '[[:alnum:]]')
|
||||||
echo " <key>${line}</key>
|
echo " <key>${line}</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>SOGoMailDomain</key>
|
<key>SOGoMailDomain</key>
|
||||||
<string>$(echo ${line} | tr '-' 'b' | tr '.' 'p')</string>
|
<string>$(echo ${line} | tr '-' 'b' | tr '.' 'p')</string>
|
||||||
|
@ -73,8 +76,8 @@ echo " <key>${line}</key>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
</dict>" >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
</dict>" >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
||||||
mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "DROP VIEW IF EXISTS sogo_view_${DOMAIN_SANE}"
|
mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "DROP VIEW IF EXISTS sogo_view_${DOMAIN_SANE}"
|
||||||
mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} << EOF
|
mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} << EOF
|
||||||
CREATE VIEW sogo_view_${DOMAIN_SANE} (c_uid, c_name, c_password, c_cn, mail, aliases, ad_aliases, senderacl, home) AS
|
CREATE VIEW sogo_view_${DOMAIN_SANE} (c_uid, c_name, c_password, c_cn, mail, aliases, ad_aliases, senderacl, home) AS
|
||||||
SELECT mailbox.username, mailbox.username, mailbox.password, mailbox.name, mailbox.username, IFNULL(ga.aliases, ''), IFNULL(gda.ad_alias, ''), IFNULL(gs.send_as, ''), CONCAT('/var/vmail/', maildir) FROM mailbox
|
SELECT mailbox.username, mailbox.username, mailbox.password, mailbox.name, mailbox.username, IFNULL(ga.aliases, ''), IFNULL(gda.ad_alias, ''), IFNULL(gs.send_as, ''), CONCAT('/var/vmail/', maildir) FROM mailbox
|
||||||
LEFT OUTER JOIN grouped_mail_aliases ga ON ga.username = mailbox.username
|
LEFT OUTER JOIN grouped_mail_aliases ga ON ga.username = mailbox.username
|
||||||
|
@ -84,13 +87,15 @@ WHERE mailbox.active = '1' AND domain = '${line}';
|
||||||
EOF
|
EOF
|
||||||
done < <(mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain;" -B -N)
|
done < <(mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain;" -B -N)
|
||||||
|
|
||||||
# Generate footer
|
# Generate footer
|
||||||
echo ' </dict>
|
echo ' </dict>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>' >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
</plist>' >> /var/lib/sogo/GNUstep/Defaults/sogod.plist
|
||||||
|
|
||||||
# Fix permissions
|
# Fix permissions
|
||||||
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
|
||||||
|
|
||||||
exec "$@"
|
sleep 300
|
||||||
|
|
||||||
|
done
|
|
@ -7,10 +7,19 @@ redirect_stderr=true
|
||||||
autostart=true
|
autostart=true
|
||||||
stdout_syslog=true
|
stdout_syslog=true
|
||||||
|
|
||||||
|
[group:sogo-group]
|
||||||
|
programs=reconf-domains,sogo
|
||||||
|
|
||||||
[program:sogo]
|
[program:sogo]
|
||||||
command=/usr/sbin/sogod
|
command=/usr/sbin/sogod
|
||||||
user=sogo
|
user=sogo
|
||||||
autorestart=true
|
autorestart=true
|
||||||
|
priority=20
|
||||||
|
|
||||||
|
[program:reconf-domains]
|
||||||
|
command=/reconf-domains.sh
|
||||||
|
autorestart=true
|
||||||
|
priority=10
|
||||||
|
|
||||||
[program:sogo-syslog]
|
[program:sogo-syslog]
|
||||||
command=/usr/bin/tail -f /var/log/syslog -f /var/log/sogo/sogo.log
|
command=/usr/bin/tail -f /var/log/syslog -f /var/log/sogo/sogo.log
|
||||||
|
@ -21,6 +30,11 @@ stdout_logfile_maxbytes=0
|
||||||
command=/usr/sbin/cron -f
|
command=/usr/sbin/cron -f
|
||||||
autorestart=true
|
autorestart=true
|
||||||
|
|
||||||
#[unix_http_server]
|
[inet_http_server]
|
||||||
#file=/var/run/controller/supervisord.sock
|
port=9191
|
||||||
#chown=www-data:nogroup
|
|
||||||
|
[rpcinterface:supervisor]
|
||||||
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||||
|
|
||||||
|
[supervisorctl]
|
||||||
|
serverurl=http://localhost:9191
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
$AuthUsers = array("admin");
|
||||||
|
if (!isset($_SESSION['mailcow_cc_role']) OR !in_array($_SESSION['mailcow_cc_role'], $AuthUsers)) {
|
||||||
|
echo "Not allowed." . PHP_EOL;
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
if ($_GET['ACTION'] == "start") {
|
||||||
|
$request = xmlrpc_encode_request("supervisor.startProcessGroup", 'sogo-group', 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>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($_GET['ACTION'] == "stop") {
|
||||||
|
$request = xmlrpc_encode_request("supervisor.stopProcessGroup", 'sogo-group', 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>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
|
@ -1,3 +1,26 @@
|
||||||
|
<?php
|
||||||
|
if ($_SESSION['mailcow_cc_role'] == "admin"):
|
||||||
|
?>
|
||||||
|
<div id="RestartSOGo" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title">Restart SOGo</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Some tasks, e.g. adding a domain, require you to restart SOGo to catch changes made in the mailcow UI.</p>
|
||||||
|
<hr />
|
||||||
|
<button class="btn btn-md btn-primary" id="triggerRestartSogo">Restart SOGo</button>
|
||||||
|
<br /><br />
|
||||||
|
<div id="statusTriggerRestartSogo"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js"></script>
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/7.0.2/bootstrap-slider.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/7.0.2/bootstrap-slider.min.js"></script>
|
||||||
|
@ -59,6 +82,34 @@ $(document).ready(function() {
|
||||||
// Init Bootstrap Selectpicker
|
// Init Bootstrap Selectpicker
|
||||||
$('select').selectpicker();
|
$('select').selectpicker();
|
||||||
|
|
||||||
|
// Trigger SOGo restart
|
||||||
|
$('#triggerRestartSogo').click(function(){
|
||||||
|
$(this).prop("disabled",true);
|
||||||
|
$('#statusTriggerRestartSogo').text('Stopping SOGo workers, this may take a while... ');
|
||||||
|
$.ajax({
|
||||||
|
method: 'get',
|
||||||
|
url: 'call_sogo_ctrl.php',
|
||||||
|
data: {
|
||||||
|
'ajax': true,
|
||||||
|
'ACTION': 'stop'
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$('#statusTriggerRestartSogo').append(data);
|
||||||
|
$('#statusTriggerRestartSogo').append('<br />Starting SOGo... ');
|
||||||
|
$.ajax({
|
||||||
|
method: 'get',
|
||||||
|
url: 'call_sogo_ctrl.php',
|
||||||
|
data: {
|
||||||
|
'ajax': true,
|
||||||
|
'ACTION': 'start'
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$('#statusTriggerRestartSogo').append(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -199,6 +199,13 @@ endif;
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<?php
|
||||||
|
if ($_SESSION['mailcow_cc_role'] == "admin"):
|
||||||
|
?>
|
||||||
|
<li><a href data-toggle="modal" data-target="#RestartSOGo"><span style="font-size:12px" class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Restart SOGo</a></li>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if (isset($_SESSION['mailcow_cc_username'])):
|
if (isset($_SESSION['mailcow_cc_username'])):
|
||||||
|
|
|
@ -9,7 +9,7 @@ $(document).ready(function() {
|
||||||
$("#numRowsDomain").text(rowCountDomain);
|
$("#numRowsDomain").text(rowCountDomain);
|
||||||
$("#numRowsMailbox").text(rowCountMailbox);
|
$("#numRowsMailbox").text(rowCountMailbox);
|
||||||
$("#numRowsAlias").text(rowCountAlias);
|
$("#numRowsAlias").text(rowCountAlias);
|
||||||
|
|
||||||
// Filter table function
|
// Filter table function
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
filterTable: function(){
|
filterTable: function(){
|
||||||
|
|
|
@ -150,7 +150,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr id="no-data">
|
<tr id="no-data">
|
||||||
<td colspan="8" style="text-align: center; font-style: normal; border-top: 1px solid #e7e7e7;">
|
<td colspan="8" style="text-align: center; font-style: normal; border-top: 1px solid #e7e7e7;">
|
||||||
<a href="/add.php?domain" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-plus"></span> <?=$lang['mailbox']['add_domain'];?></a>
|
<a href="/add.php?domain"><?=$lang['mailbox']['add_domain'];?></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
@ -238,7 +238,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr id="no-data">
|
<tr id="no-data">
|
||||||
<td colspan="8" style="text-align: center; border-top: 1px solid #e7e7e7;">
|
<td colspan="8" style="text-align: center; border-top: 1px solid #e7e7e7;">
|
||||||
<a href="/add.php?aliasdomain" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-plus"></span> <?=$lang['mailbox']['add_domain_alias'];?></a>
|
<a href="/add.php?aliasdomain"><?=$lang['mailbox']['add_domain_alias'];?></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
@ -368,7 +368,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr id="no-data">
|
<tr id="no-data">
|
||||||
<td colspan="8" style="text-align: center; border-top: 1px solid #e7e7e7;">
|
<td colspan="8" style="text-align: center; border-top: 1px solid #e7e7e7;">
|
||||||
<a href="/add.php?mailbox" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-plus"></span> <?=$lang['mailbox']['add_mailbox'];?></a>
|
<a href="/add.php?mailbox"><?=$lang['mailbox']['add_mailbox'];?></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
@ -479,7 +479,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr id="no-data">
|
<tr id="no-data">
|
||||||
<td colspan="8" style="text-align: center; border-top: 1px solid #e7e7e7;">
|
<td colspan="8" style="text-align: center; border-top: 1px solid #e7e7e7;">
|
||||||
<a href="/add.php?alias" class="btn btn-xs btn-primary"><span class="glyphicon glyphicon-plus"></span> <?=$lang['mailbox']['add_alias'];?></a>
|
<a href="/add.php?alias"><?=$lang['mailbox']['add_alias'];?></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
|
Loading…
Reference in New Issue