Commit 57496f7c authored by Marius Cramer's avatar Marius Cramer

Merge branch 'renky/ispconfig3-mdbox-format'

Conflicts:
	install/sql/incremental/upd_dev_collection.sql
parents 54f10546 465dd856
......@@ -37,6 +37,7 @@ ALTER TABLE `web_backup` CHANGE `filesize` `filesize` VARCHAR(20) NOT NULL DEFAU
ALTER TABLE `sys_datalog` ADD INDEX `dbtable` (`dbtable` (25), `dbidx` (25)), ADD INDEX (`action`);
ALTER TABLE `mail_user` ADD `greylisting` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `postfix`;
ALTER TABLE `mail_user` ADD `maildir_format` varchar(255) NOT NULL default 'maildir' AFTER `maildir`;
ALTER TABLE `mail_forwarding` ADD `greylisting` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `active`;
ALTER TABLE `openvz_ip` CHANGE `ip_address` `ip_address` VARCHAR(39) DEFAULT NULL;
......
......@@ -915,6 +915,7 @@ CREATE TABLE `mail_user` (
`uid` int(11) NOT NULL default '5000',
`gid` int(11) NOT NULL default '5000',
`maildir` varchar(255) NOT NULL default '',
`maildir_format` varchar(255) NOT NULL default 'maildir',
`quota` bigint(20) NOT NULL default '-1',
`cc` varchar(255) NOT NULL default '',
`sender_cc` varchar(255) NOT NULL default '',
......
......@@ -14,8 +14,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
......
......@@ -121,8 +121,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
......
......@@ -134,8 +134,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
......
......@@ -134,8 +134,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
......
......@@ -295,6 +295,12 @@ $form["tabs"]['mail'] = array(
'width' => '40',
'maxlength' => '255'
),
'maildir_format' => array(
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => '20',
'value' => array('maildir' => 'Maildir', 'mdbox' => 'mdbox')
),
'homedir_path' => array(
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Модул';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI: Requisições máximas';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Módulo';
$wb['maildir_path_txt'] = 'Caminho do diretório Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Caminho do diretório Home';
$wb['mailuser_uid_txt'] = 'UID usuário de email';
$wb['mailuser_gid_txt'] = 'GID usuário de email';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. požadavků';
$wb['fastcgi_bin_txt'] = 'FastCGI cesta k binarnímu balíčku';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Cesta k mail adresáři';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Cesta k domácímu adresáři';
$wb['mailuser_uid_txt'] = 'Mail uživatel UID';
$wb['mailuser_gid_txt'] = 'Mail uživatel GID';
......
......@@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Anfragen';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Maildir Pfad';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Pfad';
$wb['dkim_path_txt'] = 'DKIM Pfad';
$wb['mailuser_uid_txt'] = 'Mailbenutzer UID';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'Όριο πλήθους αιτήσεων Fast
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Άρθρωμα';
$wb['maildir_path_txt'] = 'Διαδρομή Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Διαδρομή Homedir';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -29,6 +29,7 @@ $wb["fastcgi_max_requests_txt"] = 'FastCGI max. Requests';
$wb["fastcgi_bin_txt"] = 'FastCGI Bin';
$wb["module_txt"] = 'Module';
$wb["maildir_path_txt"] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb["homedir_path_txt"] = 'Homedir Path';
$wb["dkim_path_txt"] = 'DKIM Path';
$wb["mailuser_uid_txt"] = 'Mailuser UID';
......
......@@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'Peticiones máximas de FastCGI';
$wb['fastcgi_bin_txt'] = 'Binario de FastCGI';
$wb['module_txt'] = 'Módulo';
$wb['maildir_path_txt'] = 'Ruta de buzones';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Ruta base de correo';
$wb['mailuser_uid_txt'] = 'UID del usuario de correo';
$wb['mailuser_gid_txt'] = 'GID del usuario de correo';
......
......@@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI-pyyntöraja';
$wb['fastcgi_bin_txt'] = 'FastCGI-binääri';
$wb['module_txt'] = 'Ohjelmaosio';
$wb['maildir_path_txt'] = 'Postilaatikon hakemistopolku';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Kotikansion hakemistopolku';
$wb['mailuser_uid_txt'] = 'Käyttäjätunnus';
$wb['mailuser_gid_txt'] = 'Käyttäjäryhmä';
......
......@@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'Nombre maximal de requês FastCGI';
$wb['fastcgi_bin_txt'] = 'Exétable FastCGI';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Chemin Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Chemin Homedir';
$wb['mailuser_uid_txt'] = 'UID de l\'utilisateur mail';
$wb['mailuser_gid_txt'] = 'GID de l\'utilisateur mail';
......
......@@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'Maks. broj FastCGI zahtjeva';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Put do Maildir-a';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Put do početne stranice';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'Maks. Request FastCGI';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Path Direktori Mail';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Path Direktori Home';
$wb['mailuser_uid_txt'] = 'UID Pengguna Mail';
$wb['mailuser_gid_txt'] = 'GID Pengguna Mail';
......
......@@ -16,6 +16,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI 最大リクエスト数';
$wb['fastcgi_bin_txt'] = 'FastCGI実行ファイル';
$wb['module_txt'] = 'モジュール';
$wb['maildir_path_txt'] = 'メールディレクトリ';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'ホームディレクトリ';
$wb['mailuser_uid_txt'] = 'メールユーザーのUID';
$wb['mailuser_gid_txt'] = 'メールユーザーのGID';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. gequests';
$wb['fastcgi_bin_txt'] = 'FastCGI bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir pad';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir pad';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'Maksymalna ilość zadań FastCGI';
$wb['fastcgi_bin_txt'] = 'Kosz FastCGI';
$wb['module_txt'] = 'Moduł';
$wb['maildir_path_txt'] = 'Adres poczty e-mail';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Bazowy adres poczty e-mail';
$wb['mailuser_uid_txt'] = 'UID użytkownika e-mail';
$wb['mailuser_gid_txt'] = 'GID użytkownika e-mail';
......
......@@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI: Requisições máximas';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Módulo';
$wb['maildir_path_txt'] = 'Pasta do Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Pasta Home';
$wb['mailuser_uid_txt'] = 'UID utilizador de email';
$wb['mailuser_gid_txt'] = 'GID utilizador de email';
......
......@@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -16,6 +16,7 @@ $wb['fastcgi_max_requests_txt'] = 'Макс.запросов для FastCGI';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Модуль';
$wb['maildir_path_txt'] = 'Путь Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Путь Homedir';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Maildir Cesta';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Cesta k domovskému adresáru';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
......
......@@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests';
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modül';
$wb['maildir_path_txt'] = 'Mail dizini yolu';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Kullanıcı dizini yolu';
$wb['mailuser_uid_txt'] = 'Mail kullanıcısı UID';
$wb['mailuser_gid_txt'] = 'Mail kullanıcısı GID';
......
......@@ -14,6 +14,12 @@
<div class="form-group">
<label for="maildir_path" class="col-sm-3 control-label">{tmpl_var name='maildir_path_txt'}</label>
<div class="col-sm-9"><input type="text" name="maildir_path" id="maildir_path" value="{tmpl_var name='maildir_path'}" class="form-control" /></div></div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='maildir_format_txt'}</label>
<div class="col-sm-9"><select name="maildir_format" id="maildir_format" class="form-control">
{tmpl_var name='maildir_format'}
</select></div>
</div>
<div class="form-group">
<label for="homedir_path" class="col-sm-3 control-label">{tmpl_var name='homedir_path_txt'}</label>
<div class="col-sm-9"><input type="text" name="homedir_path" id="homedir_path" value="{tmpl_var name='homedir_path'}" class="form-control" /></div></div>
......
......@@ -207,6 +207,16 @@ class page_action extends tform_actions {
$app->uses('getconf');
$mail_config = $app->getconf->get_server_config(!empty($domain["server_id"]) ? $domain["server_id"] : '', 'mail');
// Set Maildir format
if ($this->id == 0) {
$this->dataRecord['maildir_format'] = $sys_config['maildir_format'];
}
else {
// restore Maildir format
$tmp = $app->db->queryOneRecord("SELECT maildir_format FROM mail_user WHERE mailuser_id = ".$app->functions->intval($this->id));
$this->dataRecord['maildir_format'] = $tmp['maildir_format'];
}
//* compose the email field
if(isset($_POST["email_local_part"]) && isset($_POST["email_domain"])) {
$this->dataRecord["email"] = strtolower($_POST["email_local_part"]."@".$app->functions->idn_encode($_POST["email_domain"]));
......
......@@ -31,6 +31,7 @@ class cronjob_backup_mail extends cronjob {
// job schedule
protected $_schedule = '0 0 * * *';
private $tmp_backup_dir = '';
/* this function is optional if it contains no custom code */
public function onPrepare() {
......@@ -111,23 +112,46 @@ class cronjob_backup_mail extends cronjob {
$mail_backup_file = 'mail'.$rec['mailuser_id'].'_'.date('Y-m-d_H-i');
$domain_dir=explode('/',$rec['maildir']);
$_temp=array_pop($domain_dir);unset($_temp);
$domain_dir=implode('/',$domain_dir);
$parts=explode('/',$rec['maildir']);
$source_dir=array_pop($parts);
unset($parts);
//* create archives
if($backup_mode == 'userzip') {
$mail_backup_file.='.zip';
exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/null', $tmp_output, $retval);
} else {
/* Create a tar.gz backup */
$mail_backup_file.='.tar.gz';
exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval);
// in case of mdbox -> create backup with doveadm before zipping
if ($rec['maildir_format'] == 'mdbox') {
if (empty($this->tmp_backup_dir)) $this->tmp_backup_dir = $rec['maildir'];
// Create temporary backup-mailbox
exec("su -c 'dsync backup -u \"".$rec["email"]."\" mdbox:".$this->tmp_backup_dir."/backup'", $tmp_output, $retval);
if($backup_mode == 'userzip') {
$mail_backup_file.='.zip';
exec('cd '.$this->tmp_backup_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r backup > /dev/null && rm -rf backup', $tmp_output, $retval);
}
else {
$mail_backup_file.='.tar.gz';
exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$this->tmp_backup_dir.' backup && rm -rf '.$this->tmp_backup_dir.'/backup'), $tmp_output, $retval);
}
if ($retval != 0) {
// Cleanup
if (file_exists($this->tmp_backup_dir.'/backup')) exec('rm -rf '.$this->tmp_backup_dir.'/backup');
}
}
else {
$domain_dir=explode('/',$rec['maildir']);
$_temp=array_pop($domain_dir);unset($_temp);
$domain_dir=implode('/',$domain_dir);
$parts=explode('/',$rec['maildir']);
$source_dir=array_pop($parts);
unset($parts);
//* create archives
if($backup_mode == 'userzip') {
$mail_backup_file.='.zip';
exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/null', $tmp_output, $retval);
} else {
/* Create a tar.gz backup */
$mail_backup_file.='.tar.gz';
exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval);
}
}
if($retval == 0){
chown($mail_backup_dir.'/'.$mail_backup_file, $backupusername);
chgrp($mail_backup_dir.'/'.$mail_backup_file, $backupgroup);
......@@ -141,6 +165,10 @@ class cronjob_backup_mail extends cronjob {
} else {
/* Backup failed - remove archive */
if(is_file($mail_backup_dir.'/'.$mail_backup_file)) unlink($mail_backup_dir.'/'.$mail_backup_file);
// And remove backup-mdbox
if ($rec['maildir_format'] == 'mdbox') {
if(file_exists($rec['maildir'].'/backup')) exec("su -c 'rm -rf ".$rec['maildir']."/backup'");
}
$app->log($mail_backup_file.' NOK:'.implode('',$tmp_output), LOGLEVEL_DEBUG);
}
/* Remove old backups */
......
<?php
/*
Copyright (c) 2015, Dominik Müller, Profi Webdesign
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class cronjob_purge_mailboxes extends cronjob {
// should run before quota notify and backup
// quota notify and backup is both '0 0 * * *'
// job schedule
protected $_schedule = '30 23 * * *';
/* this function is optional if it contains no custom code */
public function onPrepare() {
global $app;
parent::onPrepare();
}
/* this function is optional if it contains no custom code */
public function onBeforeRun() {
global $app;
return parent::onBeforeRun();
}
public function onRunJob() {
global $app, $conf;
$sql = "SELECT email FROM mail_user WHERE maildir_format = 'mdbox' AND server_id = ".$server_id;
$records = $app->db->queryAllRecords($sql);
if(is_array($records)) {
foreach($records as $rec){
exec("su -c 'doveadm purge -u \"".$rec["email"]."\"'");
}
}
parent::onRunJob();
}
/* this function is optional if it contains no custom code */
public function onAfterRun() {
global $app;
parent::onAfterRun();
}
}
?>
......@@ -204,27 +204,68 @@ class backup_plugin {
chown($domain_dir, $mail_config['mailuser_name']);
chgrp($domain_dir, $mail_config['mailuser_group']);
}
if (!is_dir($record['maildir'])) {
mkdir($record['maildir'], 0700); //* never create the full path
chown($record['maildir'], $mail_config['mailuser_name']);
chgrp($record['maildir'], $mail_config['mailuser_group']);
}
if(file_exists($mail_backup_file) && $record['homedir'] != '' && $record['homedir'] != '/' && !stristr($mail_backup_file,'..') && !stristr($mail_backup_file,'etc') && $mail_config['homedir_path'] == $record['homedir'] && is_dir($domain_dir)) {
if($mail_backup['backup_mode'] == 'userzip') {
copy($mail_backup_file, $domain_dir.'/'.$mail_backup['filename']);
chgrp($domain_dir.'/'.$mail_backup['filename'], $mail_config['mailuser_group']);
$command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o '.escapeshellarg($domain_dir.'/'.$mail_backup['filename']).' -d '.escapeshellarg($domain_dir).' 2> /dev/null';
exec($command,$tmp_output, $retval);
unlink($domain_dir.'/'.$mail_backup['filename']);
if(file_exists($mail_backup_file) && $record['homedir'] != '' && $record['homedir'] != '/' && !stristr($mail_backup_file,'..') && !stristr($mail_backup_file,'etc') && $mail_config['homedir_path'] == $record['homedir'] && is_dir($domain_dir) && is_dir($record['maildir'])) {
if ($record['maildir_format'] == 'mdbox') {
$retval = -1;
// First unzip backupfile to local backup-folder
if($mail_backup['backup_mode'] == 'userzip') {
copy($mail_backup_file, $record['maildir'].'/'.$mail_backup['filename']);
chgrp($record['maildir'].'/'.$mail_backup['filename'], $mail_config['mailuser_group']);
$command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o '.escapeshellarg($record['maildir'].'/'.$mail_backup['filename']).' -d '.escapeshellarg($record['maildir']).' 2> /dev/null';
exec($command,$tmp_output, $retval);
unlink($record['maildir'].'/'.$mail_backup['filename']);
}
if($mail_backup['backup_mode'] == 'rootgz') {
$command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($record['maildir']);
exec($command,$tmp_output, $retval);
}
if($retval == 0) {
// Now import backup-mailbox into special backup-folder
$backupname = "backup-".date("Y-m-d", $mail_backup['tstamp']);
exec("doveadm mailbox create -u \"".$record["email"]."\" $backupname");
exec("doveadm import -u \"".$record["email"]."\" mdbox:".$record['maildir']."/backup $backupname all", $tmp_output, $retval);
exec("for f in `doveadm mailbox list -u \"".$record["email"]."\" $backupname*`; do doveadm mailbox subscribe -u \"".$record["email"]."\" \$f; done", $tmp_output, $retval);
exec('rm -rf '.$record['maildir'].'/backup');
}
if($retval == 0){
$app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
} else {
// cleanup
if (file_exists($record['maildir'].'/'.$mail_backup['filename'])) unlink($record['maildir'].'/'.$mail_backup['filename']);
if (file_exists($record['maildir']."/backup")) exec('rm -rf '.$record['maildir']."/backup");
$app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
}
}
if($mail_backup['backup_mode'] == 'rootgz') {
$command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($domain_dir);
exec($command,$tmp_output, $retval);
if($retval == 0){
$app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
} else {
$app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
else {
if($mail_backup['backup_mode'] == 'userzip') {
copy($mail_backup_file, $domain_dir.'/'.$mail_backup['filename']);
chgrp($domain_dir.'/'.$mail_backup['filename'], $mail_config['mailuser_group']);
$command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o '.escapeshellarg($domain_dir.'/'.$mail_backup['filename']).' -d '.escapeshellarg($domain_dir).' 2> /dev/null';
exec($command,$tmp_output, $retval);
unlink($domain_dir.'/'.$mail_backup['filename']);
if($retval == 0){
$app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
} else {
$app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
}
}
if($mail_backup['backup_mode'] == 'rootgz') {
$command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($domain_dir);
exec($command,$tmp_output, $retval);
if($retval == 0){
$app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
} else {
$app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment