diff --git a/install/dist/conf/debian100.conf.php b/install/dist/conf/debian100.conf.php index b23bbbf32c3a64a8fc949e4a347ee5c8555b1b7d..2a02fb53c867e6fcc7dc67123aa30934d9e3b48e 100644 --- a/install/dist/conf/debian100.conf.php +++ b/install/dist/conf/debian100.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debian110.conf.php b/install/dist/conf/debian110.conf.php index a1754722e56f773f20dbd3cb61391bc74e7be659..e7f0507f77313dba51c91ac86b0b25cfc62ca62c 100644 --- a/install/dist/conf/debian110.conf.php +++ b/install/dist/conf/debian110.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debian120.conf.php b/install/dist/conf/debian120.conf.php index bd6773c62306e3eedc12fe487f6290ce51b2c133..b2284ae78c80e773b9ebb0353712999e92a63e52 100644 --- a/install/dist/conf/debian120.conf.php +++ b/install/dist/conf/debian120.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debian90.conf.php b/install/dist/conf/debian90.conf.php index 64e22fea285a6a014027c531cdc9ca9b152d97ee..893ab6ec89166d9d676a98a38371202df7b87668 100644 --- a/install/dist/conf/debian90.conf.php +++ b/install/dist/conf/debian90.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debiantesting.conf.php b/install/dist/conf/debiantesting.conf.php index 145e213d0c55992e9475b0f13a831845bdadeab7..d5a58b8a9a8133bbd10d4dc18f14d439bb169aad 100644 --- a/install/dist/conf/debiantesting.conf.php +++ b/install/dist/conf/debiantesting.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/ubuntu1804.conf.php b/install/dist/conf/ubuntu1804.conf.php index 6dc51a13c77a776389002b1ed4485372b462eb31..a2f38c0feea2381d22423260f90b250836870b70 100644 --- a/install/dist/conf/ubuntu1804.conf.php +++ b/install/dist/conf/ubuntu1804.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* Getmail $conf['getmail']['installed'] = false; // will be detected automatically during installation $conf['getmail']['config_dir'] = '/etc/getmail'; diff --git a/install/dist/conf/ubuntu2004.conf.php b/install/dist/conf/ubuntu2004.conf.php index a55c9a004be57ee4ca99f61ce8a6025ae64736bf..fc8289e65682af888b857a5c32abd57665de62fd 100644 --- a/install/dist/conf/ubuntu2004.conf.php +++ b/install/dist/conf/ubuntu2004.conf.php @@ -122,6 +122,12 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + + //* Getmail $conf['getmail']['installed'] = false; // will be detected automatically during installation $conf['getmail']['config_dir'] = '/etc/getmail'; diff --git a/install/dist/conf/ubuntu2204.conf.php b/install/dist/conf/ubuntu2204.conf.php index 050f58f69d479acffc8dd72b038946de4fa929af..ec78b404fde7544aaeb729ce0afbe3678791ed14 100644 --- a/install/dist/conf/ubuntu2204.conf.php +++ b/install/dist/conf/ubuntu2204.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* Getmail $conf['getmail']['installed'] = false; // will be detected automatically during installation $conf['getmail']['config_dir'] = '/etc/getmail'; diff --git a/install/install.php b/install/install.php index 114410b53c1b292053478155354411099207339d..71380103f01fcc95232bf1a3c1d19bbd1d5282db 100644 --- a/install/install.php +++ b/install/install.php @@ -356,6 +356,13 @@ if($install_mode == 'standard' || strtolower($inst->simple_query('Configure Mail $inst->configure_mailman(); } + //* Configure Sympa + $force = @($conf['sympa']['installed']) ? true : $inst->force_configure_app('Sympa', ($install_mode == 'expert')); + if($force) { + swriteln('Configuring Sympa'); + $inst->configure_sympa(); + } + //* Check for Dovecot and Courier if(!$conf['dovecot']['installed'] && !$conf['courier']['installed']) { $conf['dovecot']['installed'] = $inst->force_configure_app('Dovecot', ($install_mode == 'expert')); @@ -652,6 +659,7 @@ if($conf['courier']['installed'] == true){ } if($conf['dovecot']['installed'] == true && isset($conf['dovecot']['init_script']) && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); if($conf['mailman']['installed'] == true && isset($conf['mailman']['init_script']) && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &'); +if($conf['sympa']['installed'] == true && isset($conf['sympa']['init_script']) && $conf['sympa']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['sympa']['init_script'], 'restart').' >/dev/null 2>&1 &'); if($conf['apache']['installed'] == true && isset($conf['apache']['init_script']) && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart')); //* Reload is enough for nginx if($conf['nginx']['installed'] == true){ diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 8e6cfca07b494eb3bb07034e164baf0315ca6d37..c0b6a5dff428feb13259cb588276f78aa2b4ca8f 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -211,6 +211,7 @@ class installer_base extends stdClass { if(is_installed('postfix')) $conf['postfix']['installed'] = true; if(is_installed('postgrey')) $conf['postgrey']['installed'] = true; if(is_installed('mailman') || is_installed('mmsitepass')) $conf['mailman']['installed'] = true; + if(is_installed('sympa')) $conf['sympa']['installed'] = true; if(is_installed('apache') || is_installed('apache2') || is_installed('httpd') || is_installed('httpd2')) $conf['apache']['installed'] = true; if(is_installed('getmail')) $conf['getmail']['installed'] = true; if(is_installed('courierlogger')) $conf['courier']['installed'] = true; @@ -1031,6 +1032,120 @@ class installer_base extends stdClass { exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); } + public function configure_sympa($status = 'insert') { + global $conf; + + # https://www.sympa.community/manual/install/configure-mail-server-postfix.html + $data_dir = '/var/lib/sympa'; + if (($conf['sympa']['installed'] != true) && is_dir($data_dir)) { + rename($data_dir, $data_dir . '-bk'); + //* Create the Sympa files + if(!is_dir('/etc/sympa')) exec('mkdir -p /etc/sympa'); + if(!is_file('/etc/sympa/transport.sympa')) touch('/etc/sympa/transport.sympa'); + if(!is_file('/etc/sympa/virtual.sympa')) touch('/etc/sympa/virtual.sympa'); + if(!is_file('/etc/sympa/sympa_transport')) touch('/etc/sympa/sympa_transport'); + chmod('/etc/sympa/sympa_transport', 0644); + chown('/etc/sympa/sympa_transport', 'sympa'); + chgrp('/etc/sympa/sympa_transport', 'sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); + exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); + exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); + chmod('etc/sympa/sympa_transport', 0640); + chmod('etc/sympa/sympa_transport.db', 0640); + chgrp('/etc/sympa/sympa_transport', 'postfix'); + chgrp('/etc/sympa/sympa_transport.db', 'postfix'); + } + + $config_dir = $conf['postfix']['config_dir']; + //* Configure master.cf and add a line for deliver + if(!$this->get_postfix_service('sympa', 'unix')) { + //* backup + if(is_file($config_dir.'/master.cf')){ + copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); + } + if(is_file($config_dir.'/master.cf~2')){ + chmod($config_dir.'/master.cf~2', 0400); + } + //* Configure master.cf and add a line for deliver + $content_master = rf($config_dir.'/master.cf'); + $deliver_content = 'sympa unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/queue ${nexthop}'."\n"; + $deliver_content .= 'sympabounce unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/bouncequeue ${nexthop}'."\n"; + af($config_dir.'/master.cf', $deliver_content); + unset($content_master); + unset($deliver_content); + } + + $config_dir = $conf['sympa']['config_dir'].'/sympa/'; + $full_file_name = $config_dir.'sympa.conf'; + //* Backup exiting file + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.'sympa.conf~'); + } + + // load files + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.conf.master', 'tpl/sympa.conf.master'); + $old_file = rf($full_file_name); + + $old_options = array(); + $lines = explode("\n", $old_file); + foreach ($lines as $line) + { + if (trim($line) != '' && substr($line, 0, 1) != '#') + { + @list($key, $value) = @preg_split('/\s+/', $line); + if (isset($value) && $value !== '') + { + $key = rtrim($key); + $old_options[$key] = trim($value); + } + } + } + + $content = str_replace('{hostname}', $conf['hostname'], $content); + + if(!isset($old_options['lang']) || $old_options['lang'] == '') $old_options['lang'] = 'en'; + $content = str_replace('{lang}', $old_options['lang'], $content); + if(!isset($old_options['listmaster']) || $old_options['listmaster'] == '') $old_options['listmaster'] = 'listmaster@'.$conf['hostname']; + $content = str_replace('{listmaster}', $old_options['listmaster'], $content); + if(!isset($old_options['db_type']) || $old_options['db_type'] == '') $old_options['db_type'] = 'mysql'; + $content = str_replace('{db_type}', $old_options['db_type'], $content); + if(!isset($old_options['db_host']) || $old_options['db_host'] == '') $old_options['db_host'] = 'localhost'; + $content = str_replace('{db_host}', $old_options['db_host'], $content); + if(!isset($old_options['db_port']) || $old_options['db_port'] == '') $old_options['db_port'] = '3306'; + $content = str_replace('{db_port}', $old_options['db_port'], $content); + if(!isset($old_options['db_name']) || $old_options['db_name'] == '') $old_options['db_name'] = 'sympa'; + $content = str_replace('{db_name}', $old_options['db_name'], $content); + if(!isset($old_options['db_user']) || $old_options['db_user'] == '') $old_options['db_user'] = 'sympa'; + $content = str_replace('{db_user}', $old_options['db_user'], $content); + if(!isset($old_options['db_passwd']) || $old_options['db_passwd'] == '') $old_options['db_passwd'] = 'your_passwd'; + $content = str_replace('{db_passwd}', $old_options['db_passwd'], $content); + + wf($full_file_name, $content); + + //* Write list_aliases.tt2 script + $config_dir = $conf['sympa']['config_dir'].'/'; + $full_file_name = $config_dir.'list_aliases.tt2'; + + //* Backup exiting list_aliases.tt2 file + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.'list_aliases.tt2~'); + } + + if(is_dir('/etc/sympa')) { + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/list_aliases.tt2')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/list_aliases.tt2', $full_file_name); + } else { + copy('tpl/list_aliases.tt2', $full_file_name); + } + chgrp($full_file_name, 'sympa'); + chmod($full_file_name, 0644); + } + + //* Create aliasaes + if($status == 'install') exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); + } + public function get_postfix_service($service, $type) { global $conf; @@ -1294,6 +1409,23 @@ class installer_base extends stdClass { if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); + //* Create the Sympa files + if(!is_dir('/etc/sympa')) exec('mkdir -p /etc/sympa'); + if(!is_file('/etc/sympa/transport.sympa')) touch('/etc/sympa/transport.sympa'); + if(!is_file('/etc/sympa/virtual.sympa')) touch('/etc/sympa/virtual.sympa'); + if(!is_file('/etc/sympa/sympa_transport')) touch('/etc/sympa/sympa_transport'); + chmod('/etc/sympa/sympa_transport', 0644); + chown('/etc/sympa/sympa_transport', 'sympa'); + chgrp('/etc/sympa/sympa_transport', 'sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); + exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); + exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); + chmod('/etc/sympa/sympa_transport', 0640); + chmod('/etc/sympa/sympa_transport.db', 0640); + chgrp('/etc/sympa/sympa_transport', 'postfix'); + chgrp('/etc/sympa/sympa_transport.db', 'postfix'); + //* Create auxillary postfix conf files $configfile = 'helo_access'; if(is_file($config_dir.'/'.$configfile)) { diff --git a/install/tpl/apache_ispconfig.conf.master b/install/tpl/apache_ispconfig.conf.master index c968abf3679777acd99fa6b8ddbee89524d43956..96ad9eab20884ab30a48d47c71530c8dcca33019 100644 --- a/install/tpl/apache_ispconfig.conf.master +++ b/install/tpl/apache_ispconfig.conf.master @@ -136,6 +136,30 @@ CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m Alias /awstats-icon "/usr/share/awstats/icon" +# Sympa Configuration + + Alias /static-sympa /usr/share/sympa/static_content + + Require all granted + + + Alias /css-sympa /var/lib/sympa/css + + Require all granted + + + Alias /pictures-sympa /var/lib/sympa/pictures + + Require all granted + + + + SetHandler "proxy:unix:/run/sympa/wwsympa.socket|fcgi://" + Require all granted + + + + NameVirtualHost *:80 NameVirtualHost *:443 diff --git a/install/tpl/debian_postfix.conf.master b/install/tpl/debian_postfix.conf.master index 8bd34f6928b8a57c516bf4edd848c7892f8018c8..bc76e7bbf7fada8e593e31fad5edf815e4221d5d 100644 --- a/install/tpl/debian_postfix.conf.master +++ b/install/tpl/debian_postfix.conf.master @@ -1,9 +1,9 @@ alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases virtual_alias_domains = proxy:mysql:{config_dir}/mysql-virtual_alias_domains.cf -virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman, proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, proxy:mysql:{config_dir}/mysql-virtual_alias_maps.cf, proxy:mysql:{config_dir}/mysql-virtual_email2email.cf -virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf -virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf +virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman, proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, proxy:mysql:{config_dir}/mysql-virtual_alias_maps.cf, proxy:mysql:{config_dir}/mysql-virtual_email2email.cf, hash:/etc/sympa/virtual.sympa +virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf, hash:/etc/sympa/transport.sympa +virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf, hash:/etc/sympa/transport.sympa, hash:/etc/sympa/sympa_transport, hash:/etc/sympa/virtual.sympa virtual_mailbox_base = {vmail_mailbox_base} virtual_uid_maps = proxy:mysql:/etc/postfix/mysql-virtual_uids.cf virtual_gid_maps = proxy:mysql:/etc/postfix/mysql-virtual_gids.cf @@ -20,7 +20,7 @@ smtpd_use_tls = yes smtpd_tls_security_level = may smtpd_tls_cert_file = {config_dir}/smtpd.cert smtpd_tls_key_file = {config_dir}/smtpd.key -transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:{config_dir}/mysql-virtual_transports.cf +transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:{config_dir}/mysql-virtual_transports.cf, hash:/etc/sympa/transport.sympa, hash:/etc/sympa/sympa_transport relay_domains = proxy:mysql:{config_dir}/mysql-virtual_relaydomains.cf relay_recipient_maps = proxy:mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf smtpd_sender_login_maps = proxy:mysql:{config_dir}/mysql-virtual_sender_login_maps.cf diff --git a/install/tpl/list_aliases.tt2 b/install/tpl/list_aliases.tt2 new file mode 100644 index 0000000000000000000000000000000000000000..bb6092273527c6f010fb44045c32269c75d91163 --- /dev/null +++ b/install/tpl/list_aliases.tt2 @@ -0,0 +1,7 @@ +#--- [% list.name %]@[% list.domain %]: list transport map created at [% date %] +[% list.name %]@[% list.domain %] sympa:[% list.name %]@[% list.domain %] +[% list.name %]-request@[% list.domain %] sympa:[% list.name %]-request@[% list.domain %] +[% list.name %]-editor@[% list.domain %] sympa:[% list.name %]-editor@[% list.domain %] +#[% list.name %]-subscribe@[% list.domain %] sympa:[% list.name %]-subscribe@[%list.domain %] +[% list.name %]-unsubscribe@[% list.domain %] sympa:[% list.name %]-unsubscribe@[% list.domain %] +[% list.name %][% return_path_suffix %]@[% list.domain %] sympabounce:[% list.name %]@[% list.domain %] \ No newline at end of file diff --git a/install/tpl/nginx_apps.vhost.master b/install/tpl/nginx_apps.vhost.master index 181f4c807e2ee0761e61ef26f3f0589153703ca2..ed58d5f0baf51aa933c30a73a0613439c4057793 100644 --- a/install/tpl/nginx_apps.vhost.master +++ b/install/tpl/nginx_apps.vhost.master @@ -209,6 +209,41 @@ server { autoindex on; } + location /sympa { + include fastcgi_params; + + fastcgi_pass unix:/var/run/sympa-fastcgi; + + # If you changed wwsympa_url in sympa.conf, change this regex too! + fastcgi_split_path_info ^(/sympa)(.*)$; + + fastcgi_param SCRIPT_FILENAME $document_root/wwsympa.fcgi; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param USERID sympa; + + # According to RFC3875 (https://tools.ietf.org/html/rfc3875#section-4.1.14) in SERVER_NAME + # we should put an actual hostname user came to. For nginx it is in $host + # This will allow to run sympa multihost instances + fastcgi_param SERVER_NAME $host; + } + + location /static-sympa/css { + alias /var/lib/sympa/css; + } + + location /static-sympa/pictures { + alias /var/lib/sympa/pictures; + } + + location /static-sympa { + alias /usr/share/sympa/static_content; + } + + location ^~ /css-sympa/ { + alias /var/lib/sympa/css/; + access_log off; + } + {use_rspamd}location /rspamd/ { {use_rspamd}proxy_pass http://127.0.0.1:11334/; {use_rspamd}rewrite ^//(.*) /$1; diff --git a/install/tpl/sympa.conf.master b/install/tpl/sympa.conf.master new file mode 100644 index 0000000000000000000000000000000000000000..fc58dd10e903ef92b87785859362f0404f70a488 --- /dev/null +++ b/install/tpl/sympa.conf.master @@ -0,0 +1,113 @@ +###\\\\ Service description ////### + +## domain +## Primary mail domain name +## Example: domain mail.example.org +domain {hostname} + +## listmaster +## Email addresses of listmasters +## Email addresses of the listmasters (users authorized to perform global +## server commands). Some error reports may also be sent to these addresses. +## Listmasters can be defined for each virtual host, however, the default +## listmasters will have privileges to manage all virtual hosts. +## Example: listmaster your_email_address@domain.tld +listmaster {listmaster} + +###\\\\ Database related ////### + +## db_type +## Type of the database +## Possible types are "MySQL", "PostgreSQL", "Oracle" and "SQLite". +db_type {db_type} + +## db_host +## Hostname of the database server +## With PostgreSQL, you can also use the path to Unix Socket Directory, e.g. +## "/var/run/postgresql" for connection with Unix domain socket. +## Example: db_host localhost +db_host {db_host} + +## db_port +## Port of the database server +db_port {db_port} + +## db_name +## Name of the database +## With SQLite, this must be the full path to database file. +## With Oracle Database, this must be SID, net service name or easy connection +## identifier (to use net service name, db_host should be set to "none" and +## HOST, PORT and SERVICE_NAME should be defined in tnsnames.ora file). +db_name {db_name} + +## db_user +## User for the database connection +## Example: db_user sympa +db_user {db_user} + +## db_passwd +## Password for the database connection +## What ever you use a password or not, you must protect the SQL server (is it +## not a public internet service ?) +## Example: db_passwd your_passwd +db_passwd {db_passwd} + +###\\\\ List definition ////### + +## lang +## Language of the list +## This parameter defines the language used for the list. It is used to +## initialize a user's language preference; Sympa command reports are +## extracted from the associated message catalog. +lang {lang} + +###\\\\ Web interface parameters ////### + +## wwsympa_url +## URL prefix of web interface +## This is used to construct URLs of web interface. The protocol (either +## https:// or http://) is required. +## Example: wwsympa_url https://web.example.org/sympa +wwsympa_url https://{hostname}/wws + +## static_content_path +## Directory for static contents +static_content_path /usr/share/sympa/static_content + +## css_path +## Directory for static style sheets (CSS) +## After an upgrade, static CSS files are upgraded with the newly installed +## "css.tt2" template. Therefore, this is not a good place to store customized +## CSS files. +css_path /var/lib/sympa/css + +## css_url +## URL for style sheets (CSS) +## To use auto-generated static CSS, HTTP server have to map it with +## "css_path". +css_url /css-sympa + +## pictures_path +## Directory for subscribers pictures +pictures_path /var/lib/sympa/pictures + +## pictures_url +## URL for subscribers pictures +## HTTP server have to map it with "pictures_path" directory. +pictures_url /pictures-sympa + +## create_list +## Who is able to create lists +create_list closed + +## sendmail_aliases +## Path of the file that contains all list related aliases +sendmail_aliases /etc/sympa/sympa_transport + +## aliases_program +## Program used to update alias database +aliases_program postmap + +## aliases_db_type +## Type of alias database +aliases_db_type hash \ No newline at end of file diff --git a/install/update.php b/install/update.php index 55b711da739eeb96e9b25641816a79a5f2205848..736d218d06166ba8f259b27deba0eed6304b622d 100644 --- a/install/update.php +++ b/install/update.php @@ -462,6 +462,12 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel $inst->configure_mailman('update'); } + //** Configure Sympa + if($conf['sympa']['installed'] == true && $inst->reconfigure_app('Sympa', $reconfigure_services_answer)) { + swriteln('Configuring Sympa'); + $inst->configure_sympa('update'); + } + //** Configure Spamasassin if($inst->reconfigure_app('Spamassassin', $reconfigure_services_answer)) { swriteln('Configuring Spamassassin'); @@ -658,6 +664,7 @@ if($reconfigure_services_answer == 'yes') { } if($conf['dovecot']['installed'] == true && isset($conf['dovecot']['init_script']) && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); if($conf['mailman']['installed'] == true && isset($conf['mailman']['init_script']) && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &'); + if($conf['sympa']['installed'] == true && isset($conf['sympa']['init_script']) && $conf['sympa']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['sympa']['init_script'], 'restart').' >/dev/null 2>&1 &'); } if($conf['services']['web'] || $inst->install_ispconfig_interface) { if($conf['webserver']['server_type'] == 'apache') { diff --git a/server/conf/apache_ispconfig.conf.master b/server/conf/apache_ispconfig.conf.master index 2b6038c54aa420817a0198a4b91d8ac4455f3d56..48fd6cf2d0358fe9d270a455ec5c068f39c81727 100644 --- a/server/conf/apache_ispconfig.conf.master +++ b/server/conf/apache_ispconfig.conf.master @@ -136,6 +136,29 @@ CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m Alias /awstats-icon "/usr/share/awstats/icon" +# Sympa Configuration + + Alias /static-sympa /usr/share/sympa/static_content + + Require all granted + + + Alias /css-sympa /var/lib/sympa/css + + Require all granted + + + Alias /pictures-sympa /var/lib/sympa/pictures + + Require all granted + + + + SetHandler "proxy:unix:/run/sympa/wwsympa.socket|fcgi://" + Require all granted + + + NameVirtualHost *:80 NameVirtualHost *:443 diff --git a/server/conf/nginx_apps.vhost.master b/server/conf/nginx_apps.vhost.master index 181f4c807e2ee0761e61ef26f3f0589153703ca2..ed58d5f0baf51aa933c30a73a0613439c4057793 100644 --- a/server/conf/nginx_apps.vhost.master +++ b/server/conf/nginx_apps.vhost.master @@ -209,6 +209,41 @@ server { autoindex on; } + location /sympa { + include fastcgi_params; + + fastcgi_pass unix:/var/run/sympa-fastcgi; + + # If you changed wwsympa_url in sympa.conf, change this regex too! + fastcgi_split_path_info ^(/sympa)(.*)$; + + fastcgi_param SCRIPT_FILENAME $document_root/wwsympa.fcgi; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param USERID sympa; + + # According to RFC3875 (https://tools.ietf.org/html/rfc3875#section-4.1.14) in SERVER_NAME + # we should put an actual hostname user came to. For nginx it is in $host + # This will allow to run sympa multihost instances + fastcgi_param SERVER_NAME $host; + } + + location /static-sympa/css { + alias /var/lib/sympa/css; + } + + location /static-sympa/pictures { + alias /var/lib/sympa/pictures; + } + + location /static-sympa { + alias /usr/share/sympa/static_content; + } + + location ^~ /css-sympa/ { + alias /var/lib/sympa/css/; + access_log off; + } + {use_rspamd}location /rspamd/ { {use_rspamd}proxy_pass http://127.0.0.1:11334/; {use_rspamd}rewrite ^//(.*) /$1; diff --git a/server/conf/sympa_list_creation.xml.master b/server/conf/sympa_list_creation.xml.master new file mode 100644 index 0000000000000000000000000000000000000000..16e1ad30ea0d5ba8ca262827443f8e02144209bf --- /dev/null +++ b/server/conf/sympa_list_creation.xml.master @@ -0,0 +1,15 @@ + + + {listname} + private_working_group + {listname} + + open + editor + private + en + + {email} + + Other + diff --git a/server/plugins-available/server_services_plugin.inc.php b/server/plugins-available/server_services_plugin.inc.php index c3eb78f194656cdd847d8665ccda34da6382c652..8ee401eeb4ca70f8e9aef455c50b02a5a7e4c403 100644 --- a/server/plugins-available/server_services_plugin.inc.php +++ b/server/plugins-available/server_services_plugin.inc.php @@ -38,7 +38,7 @@ class server_services_plugin { var $services = array('mail_server', 'web_server', 'dns_server', 'db_server', 'vserver_server', 'xmpp_server'); - var $mail_plugins = array('getmail_plugin', 'mail_plugin', 'mail_plugin_dkim', 'mailman_plugin', 'postfix_filter_plugin', 'postfix_server_plugin'); + var $mail_plugins = array('getmail_plugin', 'mail_plugin', 'mail_plugin_dkim', 'mailman_plugin', 'sympa_plugin', 'postfix_filter_plugin', 'postfix_server_plugin'); var $courier_plugins = array('maildrop_plugin'); var $dovecot_plugins = array('maildeliver_plugin'); diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..144ed2d00d443c2d43fd4676aafaac0db4f1fa34 --- /dev/null +++ b/server/plugins-available/sympa_plugin.inc.php @@ -0,0 +1,264 @@ +plugins->registerEvent('mail_mailinglist_insert', 'sympa_plugin', 'insert'); + $app->plugins->registerEvent('mail_mailinglist_update', 'sympa_plugin', 'update'); + $app->plugins->registerEvent('mail_mailinglist_delete', 'sympa_plugin', 'delete'); + + } + + function insert($event_name, $data) { + global $app, $conf; + + $this->update_config(); + + // Generate a config File + if(file_exists($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master")) { + $content = file_get_contents($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master"); + } else { + $content = file_get_contents($conf["rootpath"]."/conf/sympa_list_creation.xml.master"); + } + + $content = str_replace('{listname}', $data["new"]["listname"], $content); + $content = str_replace('{domain}', $data["new"]["domain"], $content); + $content = str_replace('{email}', $data["new"]["email"], $content); + + $filename = '/tmp/sympa_list_creation'.$data["new"]['mailinglist_id'].'.xml'; + + file_put_contents($filename, $content); + + $pid = $app->system->exec_safe("nohup /usr/bin/sympa --create_list --robot ? --input_file ? >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $filename); + $running = true; + do { + exec('ps -p '.intval($pid), $out); + if (count($out) ==1) $running=false; else sleep(1); + unset($out); + } while ($running); + unset($out); + + if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); + + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); + + $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); + + } + + // The purpose of this plugin is to rewrite the main.cf file + function update($event_name, $data) { + global $app, $conf; + + $this->update_config(); + + if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { + // Password not used in Sympa, no action needed + $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); + } + } + + function delete($event_name, $data) { + global $app, $conf; + + $this->update_config(); + + $app->system->exec_safe("nohup /usr/bin/sympa --close_list=? >/dev/null 2>&1 &", $data["old"]["listname"].'@'.$data["old"]["domain"]); + + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); + } + + function update_config() { + global $app, $conf; + + // create virtual_domains list + $domainAll = $app->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); + $virtual_domains = ''; + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + + // create the domain https://github.com/sympa-community/sympa-community.github.io/blob/master/manual/install/configure-mail-server-postfix.md#adding-new-domain + if(!is_dir($this->sympa_config_dir.'/'.$domain['domain'])) mkdir($this->sympa_config_dir.'/'.$domain['domain'], 0755); + chown($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); + chgrp($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); + + /* If we need custom variable per domain, might be good for the lang + if(is_dir($this->sympa_config_dir.'/'.$domain['domain'])) { + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.robot.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.robot.conf.master', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf'); + } + chgrp($full_file_name, $this->mailman_group); + chmod($full_file_name, 0755); + }*/ + + if(!is_file($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf')) touch($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf'); + chown($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); + chgrp($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); + + //* Configure transport.sympa and add aliases + $content_transport = $this->rf($this->sympa_config_dir.'/transport.sympa'); + if(strpos($content_transport, 'sympa@'.$domain['domain']) === false){ + $this->af($this->sympa_config_dir.'/transport.sympa', "sympa@".$domain['domain']." sympa:sympa@".$domain['domain']."\n"); + } + if(strpos($content_transport, 'listmaster@'.$domain['domain']) === false){ + $this->af($this->sympa_config_dir.'/transport.sympa', "listmaster@".$domain['domain']." sympa:listmaster@".$domain['domain']."\n"); + } + if(strpos($content_transport, 'bounce@'.$domain['domain']) === false){ + $this->af($this->sympa_config_dir.'/transport.sympa', "bounce@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); + } + if(strpos($content_transport, 'abuse-feedback-report@'.$domain['domain']) === false){ + $this->af($this->sympa_config_dir.'/transport.sympa', "abuse-feedback-report@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); + } + unset($content_transport); + + //* Configure virtual.sympa and add aliases + $content_virtual = $this->rf($this->sympa_config_dir.'/virtual.sympa'); + if(strpos($content_virtual , 'sympa-request@'.$domain['domain']) === false){ + $this->af($this->sympa_config_dir.'/virtual.sympa', "sympa-request@".$domain['domain']." postmaster@".$domain['domain']."\n"); + } + if(strpos($content_virtual , 'sympa-owner@'.$domain['domain']) === false){ + $this->af($this->sympa_config_dir.'/virtual.sympa', "sympa-owner@".$domain['domain']." postmaster@".$domain['domain']."\n"); + } + unset($content_virtual); + + if(!is_dir($this->sympa_expldir_dir.'/'.$domain['domain'])) mkdir($this->sympa_expldir_dir.'/'.$domain['domain'], 0750); + chown($this->sympa_expldir_dir.'/'.$domain['domain'], 'sympa'); + chgrp($this->sympa_expldir_dir.'/'.$domain['domain'], 'sympa'); + } + + if(is_file($this->sympa_config_dir.'/virtual.sympa')) exec('postmap '.$this->sympa_config_dir.'/virtual.sympa'); + if(is_file($this->sympa_config_dir.'/transport.sympa')) exec('postmap '.$this->sympa_config_dir.'/transport.sympa'); + + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); + } + + // TODO: + // If someone has a better idea than redefining this functions + function rf($file){ + global $app; + clearstatcache(); + if(!$fp = fopen($file, 'rb')){ + $app->log('WARNING: Could not open file '.$file, 2); + return false; + } else { + if(filesize($file) > 0){ + $content = fread($fp, filesize($file)); + } else { + $content = ''; + } + fclose($fp); + return $content; + } + } + + function mkdirs($strPath, $mode = '0755'){ + if(isset($strPath) && $strPath != ''){ + //* Verzeichnisse rekursiv erzeugen + if(is_dir($strPath)){ + return true; + } + $pStrPath = dirname($strPath); + if(!mkdirs($pStrPath, $mode)){ + return false; + } + $old_umask = umask(0); + $ret_val = mkdir($strPath, octdec($mode)); + umask($old_umask); + return $ret_val; + } + return false; + } + function wf($file, $content){ + global $app; + $this->mkdirs(dirname($file)); + if(!$fp = fopen($file, 'wb')){ + $app->log('WARNING: Could not open file '.$file, 2); + return false; + } else { + fwrite($fp, $content); + fclose($fp); + return true; + } + } + + function af($file, $content){ + global $app; + $this->mkdirs(dirname($file)); + if(!$fp = fopen($file, 'ab')){ + $app->log('WARNING: Could not open file '.$file, 2); + return false; + } else { + fwrite($fp, $content); + fclose($fp); + return true; + } + } + +} // end class + +?>