Skip to content

Commit

Permalink
Merge pull request #12 from Koumbit/alternc-mailman-virtual
Browse files Browse the repository at this point in the history
Alternc mailman virtual
  • Loading branch information
albancrommer authored Jun 21, 2018
2 parents fc18031 + b9dfd6f commit f93a1ed
Show file tree
Hide file tree
Showing 29 changed files with 1,933 additions and 11 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ install:
touch $(DESTDIR)/usr/share/alternc-mailman/www/index.html

rm -f $(DESTDIR)/usr/share/alternc/panel/locales/Makefile
cp -r patches/* $(DESTDIR)/usr/share/alternc-mailman/patches
install -m 0755 upgrade_mailman_check.sh $(DESTDIR)/usr/share/alternc/install/
install -m 0644 upgrades-mailman/* $(DESTDIR)/usr/share/alternc/install/upgrades-mailman/
# Install lintian overrides
Expand Down
39 changes: 34 additions & 5 deletions bureau/class/m_mailman.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

class m_mailman {

var $is_vhost_applied;

// Constructeur
function m_mailman() {
$this->is_vhost_applied=$this->vhost_applied();
}

/* ----------------------------------------------------------------- */
/** Dummy function for translation texts.
Expand Down Expand Up @@ -151,6 +157,17 @@ function get_lst($id) {
return $login . "@" . $domain;
}

/*------------------------------------------------------------------ */
/** Boolean function used to test whether the virtual list pach was applied or not
*/

function vhost_applied(){
if (file_exists("/usr/share/alternc-mailman/patches/mailman-true-virtual.applied")) {
return true;
}else{
return false;
}
}

function hook_mail_get_details($detail) {
if ($detail['type']=='mailman') return _("Special mail address for Mailman mailing-lists. <a href='mman_list.php'>Click here to manage it.</a>");
Expand Down Expand Up @@ -244,8 +261,12 @@ function add_lst($domain,$login,$owner,$password,$password2) {
return false;
}

$name = $login;

if($this->is_vhost_applied){
$name = $login . '-' . $domain;
} else {
$name = $login;
}

if ($login=="") {
$msg->raise("ERROR","mailman",_("The login (left part of the @) is mandatory"));
return false;
Expand Down Expand Up @@ -353,9 +374,17 @@ function regenerate_lst($id) {
}
$this->del_wrapper_all($list,$domain);

$db->query("UPDATE mailman SET mailman_action='REGENERATE' WHERE id=$id");
$this->del_wrapper_all($login,$domain);

if($this->is_vhost_applied){
if("$login" == "$list"){
$login = $login . '-' . $domain;
$db->query("UPDATE mailman SET mailman_action='REGENERATE' WHERE id=$id");
$db->query("UPDATE mailman SET name='$login' WHERE id=$id");
}else{
#means we are already dealing with a virtual list
$db->query("UPDATE mailman SET mailman_action='REGENERATE' WHERE id=$id");
$this->del_wrapper_all($login,$domain);
}
}
// FIXME need to be done before re_add them
// but shouldn't be launched by the Panel
# exec("sudo /usr/lib/alternc/update_mails.sh ");
Expand Down
9 changes: 9 additions & 0 deletions debian/alternc-mailman.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /bin/sh

set -e

# Source debconf library.
. /usr/share/debconf/confmodule
db_input high alternc-mailman/patch-mailman || true
db_go || true

84 changes: 81 additions & 3 deletions debian/alternc-mailman.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,83 @@ case "$1" in
sed -e "s/%%fqdn%%/$FQDN/" < "$MAILMAN_CONFIG_TEMPLATE" > "$MAILMAN_CONFIG"
cp -a -f "$MAILMAN_CONFIG" "$MAILMAN_CONFIG_BACKUP"

MAILMAN_VERSION=`dpkg -l mailman | grep ^ii | awk '{print $3}' | sed -e s/-.*// -e 's/[^:]*://'`
echo "detected mailman version $MAILMAN_VERSION"
if [ -d "/usr/share/alternc-mailman/patches/mailman-true-virtual-$MAILMAN_VERSION.d" ] ; then
PATCHDIR="/usr/share/alternc-mailman/patches/mailman-true-virtual-$MAILMAN_VERSION.d"
else
PATCHDIR=""
PATCHFILE="/usr/share/alternc-mailman/patches/mailman-true-virtual-$MAILMAN_VERSION.patch"
fi
PATCH_MARKER="/usr/share/alternc-mailman/patches/mailman-true-virtual.applied"
if [ -h $PATCH_MARKER ]; then
PATCH_VERSION=`readlink $PATCH_MARKER | sed -e 's/^.*-//;s/\.patch$//;s/\.d$//'`
echo "mailman patch detected, version $PATCH_VERSION"
if [ "$PATCH_VERSION" = "$MAILMAN_VERSION" ]; then
echo "mailman already patched, will not patch again"
else
echo "wrong version of the patch, we assume that mailman was upgraded"
rm -f $PATCH_MARKER
fi
fi
if [ "$PATCHDIR" = "" ] ; then
if [ ! -r $PATCHFILE ]; then
echo "no patchfile for mailman $MAILMAN_VERSION"
fi
fi
if [ -r "$PATCHFILE" -o "$PATCHDIR" != "" ] ; then if [ ! -h $PATCH_MARKER ]; then
db_get alternc-mailman/patch-mailman || true
if [ "$RET" = "true" ]; then
if [ "$PATCHDIR" != "" ] ; then # we have multiple files
{
patch_ok="yes"
for pfile in $PATCHDIR/* ; do
if patch --dry-run -d/ -p0 < $pfile; then
echo "applying patch $pfile :"
if patch -d/ -p0 < $pfile; then
echo "patch applied sucessfully"
else
patch_ok="no"
echo "cannot apply patch, your mailman is probably broken now, aborting"
false
fi
else
echo "patch will not apply cleanly, aborting"
patch_ok="no"
fi
if [ "$patch_ok" = "yes" ] ; then
# this will tell alternc-mailman the patch was applied successfully
ln -fs $PATCHDIR $PATCH_MARKER
invoke-rc.d mailman restart || true
fi
done
}
else # old fashion unique patch file
{
echo "testing the patch"
if patch --dry-run -d/ -p0 < $PATCHFILE; then
echo "applying patch"
if patch -d/ -p0 < $PATCHFILE; then
echo "patch applied sucessfully"
# this will tell alternc-mailman the patch was applied successfully
ln -fs $PATCHFILE $PATCH_MARKER
invoke-rc.d mailman restart || true
else
echo "cannot apply patch, your mailman is probably broken now, aborting"
false
fi
else
echo "patch will not apply cleanly, aborting"
fi
}
fi ; fi
else
echo "not applying virtual mailman patch"
fi
fi
# tell debconf to go away, otherwise alternc.install will freeze
db_stop

# Create the "mailman" list if it does not exist yet
if [ ! -d /var/lib/mailman/lists/mailman ]; then
# Create the list :
Expand All @@ -66,10 +143,11 @@ case "$1" in
a2enmod cgi || true

# make the mailman.localdomain goes to local apache2 ;)
if grep -q "127.0.0.1.*mailman.localdomain" /etc/hosts
if ! grep -q "127.0.0.1.*mailman.localdomain" /etc/hosts
then
echo "removing a former mailman.localdomain from /etc/hosts"
sed '/127.0.0.1.*mailman.localdomain/d' /etc/hosts
echo "adding mailman.localdomain to /etc/hosts"
echo "" >>/etc/hosts
echo "127.0.0.1 mailman.localdomain" >>/etc/hosts
fi

echo "$2" >/var/lib/alternc/backups/alternc-mailman-lastversion
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
alternc-mailman (3.3.1+nmu1) oldstable; urgency=low

* readding VirtualListPatch

-- Sébastien Grenier <[email protected]> Thu, 4 Jan 2018 15:31:07 +0300

alternc-mailman (3.3) oldstable; urgency=low

* remove apache-mpm-itk patch, replace it with a dependency on our OWN mailman
Expand Down
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Source: alternc-mailman
Section: admin
Priority: optional
Maintainer: Benjamin Sonntag <[email protected]>
Build-Depends: debhelper (>= 8)
Build-Depends: debhelper (>= 8), po-debconf
Standards-Version: 3.9.4

Package: alternc-mailman
Priority: optional
Section: admin
Architecture: all
Depends: mailman (>= 2.1.23-1), mysql-client | mariadb-client, patch, alternc (>> 3.2.10), php5-cli | php-cli | php7.0-cli, ${misc:Depends}
Depends: mailman (>= 2.1), mysql-client | mariadb-client, debconf, patch, alternc (>> 3.2.10), php5-cli | php-cli | php7.0-cli, ${misc:Depends}
Description: Mailman module for AlternC
AlternC is a mutualized hosting software manager for Linux.
It allows you to manage your websites, domains, ftp, emails, aliases,
Expand Down
2 changes: 1 addition & 1 deletion debian/dirs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
etc/alternc/templates/mailman
etc/apache-ssl/conf.d
etc/alternc/apache-panel.d/
usr/lib/alternc/install.d
usr/share/alternc/install
usr/share/alternc/install/upgrades-mailman
usr/share/doc/alternc-mailman
usr/share/alternc-mailman/patches
usr/share/alternc-mailman/www
usr/share/lintian/overrides
usr/share/alternc/panel/admin
Expand Down
1 change: 1 addition & 0 deletions debian/po/POTFILES.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[type: gettext/rfc822deb] templates
43 changes: 43 additions & 0 deletions debian/po/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
# Benjamin Sonntag <[email protected]>, 2004
# Bmt91 <[email protected]>, 2012
# Bruno Marmier <[email protected]>, 2004
# DeepSurfer, 2013-2014
# Ettore Atalan <[email protected]>, 2014,2017
# poupoule2004 <[email protected]>, 2012
# Stéphane Tréboux <[email protected]>, 2012
msgid ""
msgstr ""
"Project-Id-Version: AlternC, hosting control panel\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2013-10-18 11:47+0200\n"
"PO-Revision-Date: 2017-10-07 17:08+0000\n"
"Last-Translator: Benjamin Sonntag <[email protected]>\n"
"Language-Team: German (Germany) (http://www.transifex.com/octopuce/alternc/"
"language/de_DE/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: de_DE\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. Type: boolean
#. Description
#: ../templates:1001
msgid "Do you want to patch mailman for virtual support?"
msgstr "Sie möchten den MailMan Patchen für den Virtual-Support?"

#. Type: boolean
#. Description
#: ../templates:1001
msgid ""
"The patches are in /usr/share/alternc-mailman/patches. More information "
"about the patch at http://wiki.koumbit.net/VirtualMailman."
msgstr ""
"Die Patches liegen in '/usr/share/alternc-mailman/patches'. Mehr "
"Informationen über die Patches sind unter 'http://wiki.koumbit.net/"
"VirtualMailman' nach zu lesen."
59 changes: 59 additions & 0 deletions debian/po/en.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: 0.3.1\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2008-04-24 17:46-0400\n"
"PO-Revision-Date: 2005-05-15 18:24+0200\n"
"Last-Translator: Benjamin Sonntag <[email protected]>\n"
"Language-Team: english <[email protected]>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. Type: boolean
#. Description
#: ../templates:1001
msgid "Do you want to patch mailman for virtual support?"
msgstr ""

#. Type: boolean
#. Description
#: ../templates:1001
msgid ""
"The AlternC mailman plugin can optionally patch mailman to make it support "
"same-name lists on different domains (ie. allow [email protected] and "
"[email protected] to coexist). Mailman 2.x, by default, doesn't support that "
"functionality but Koumbit.org has developped patches to make it."
msgstr ""

#. Type: boolean
#. Description
#: ../templates:1001
msgid ""
"The plugin only supports patching, no way to unpatch right now. Please "
"understand that this process will modify core Mailman code and might break "
"some functionality. It is running in production on Koumbit.org."
msgstr ""

#. Type: boolean
#. Description
#: ../templates:1001
msgid ""
"Also, note that everytime the mailman package is upgraded or reinstalled, "
"the patches will need to be reapplied manually. This can be done by "
"reconfiguring the alternc-mailman package. ."
msgstr ""

#. Type: boolean
#. Description
#: ../templates:1001
msgid ""
"The patches are in /usr/share/alternc-mailman/patches. More information "
"about the patch at http://wiki.koumbit.net/VirtualMailman."
msgstr ""
Loading

0 comments on commit f93a1ed

Please sign in to comment.