[Dovecot: Imapsync] Parse, save and show last run status (#4253)
* [imapsync] - check for errors in returned_text Signed-off-by: Kristian Feldsam <feldsam@gmail.com> * [imapsync] parse and save exit status Signed-off-by: Kristian Feldsam <feldsam@gmail.com> * [dovecot] updated image version Signed-off-by: Kristian Feldsam <feldsam@gmail.com>master
parent
e3b58c6b80
commit
54c4d7e49c
|
@ -152,18 +152,28 @@ while ($row = $sth->fetchrow_arrayref()) {
|
|||
'--noreleasecheck'];
|
||||
|
||||
try {
|
||||
$is_running = $dbh->prepare("UPDATE imapsync SET is_running = 1 WHERE id = ?");
|
||||
$is_running = $dbh->prepare("UPDATE imapsync SET is_running = 1, success = NULL, exit_status = NULL WHERE id = ?");
|
||||
$is_running->bind_param( 1, ${id} );
|
||||
$is_running->execute();
|
||||
|
||||
|
||||
run [@$generated_cmds, @$custom_params_ref], '&>', \my $stdout;
|
||||
|
||||
$update = $dbh->prepare("UPDATE imapsync SET returned_text = ? WHERE id = ?");
|
||||
|
||||
# check exit code and status
|
||||
($exit_code, $exit_status) = ($stdout =~ m/Exiting\swith\sreturn\svalue\s(\d+)\s\(([^:)]+)/);
|
||||
|
||||
$success = 0;
|
||||
if (defined $exit_code && $exit_code == 0) {
|
||||
$success = 1;
|
||||
}
|
||||
|
||||
$update = $dbh->prepare("UPDATE imapsync SET returned_text = ?, success = ?, exit_status = ? WHERE id = ?");
|
||||
$update->bind_param( 1, ${stdout} );
|
||||
$update->bind_param( 2, ${id} );
|
||||
$update->bind_param( 2, ${success} );
|
||||
$update->bind_param( 3, ${exit_status} );
|
||||
$update->bind_param( 4, ${id} );
|
||||
$update->execute();
|
||||
} catch {
|
||||
$update = $dbh->prepare("UPDATE imapsync SET returned_text = 'Could not start or finish imapsync' WHERE id = ?");
|
||||
$update = $dbh->prepare("UPDATE imapsync SET returned_text = 'Could not start or finish imapsync', success = 0 WHERE id = ?");
|
||||
$update->bind_param( 1, ${id} );
|
||||
$update->execute();
|
||||
} finally {
|
||||
|
|
|
@ -1673,6 +1673,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|||
$user1 = (!empty($_data['user1'])) ? $_data['user1'] : $is_now['user1'];
|
||||
$active = (isset($_data['active'])) ? intval($_data['active']) : $is_now['active'];
|
||||
$last_run = (isset($_data['last_run'])) ? NULL : $is_now['last_run'];
|
||||
$success = (isset($_data['success'])) ? NULL : $is_now['success'];
|
||||
$delete2duplicates = (isset($_data['delete2duplicates'])) ? intval($_data['delete2duplicates']) : $is_now['delete2duplicates'];
|
||||
$subscribeall = (isset($_data['subscribeall'])) ? intval($_data['subscribeall']) : $is_now['subscribeall'];
|
||||
$delete1 = (isset($_data['delete1'])) ? intval($_data['delete1']) : $is_now['delete1'];
|
||||
|
@ -1768,6 +1769,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|||
`exclude` = :exclude,
|
||||
`host1` = :host1,
|
||||
`last_run` = :last_run,
|
||||
`success` = :success,
|
||||
`user1` = :user1,
|
||||
`password1` = :password1,
|
||||
`mins_interval` = :mins_interval,
|
||||
|
@ -1794,6 +1796,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|||
':user1' => $user1,
|
||||
':password1' => $password1,
|
||||
':last_run' => $last_run,
|
||||
':success' => $success,
|
||||
':mins_interval' => $mins_interval,
|
||||
':port1' => $port1,
|
||||
':enc1' => $enc1,
|
||||
|
|
|
@ -3,7 +3,7 @@ function init_db_schema() {
|
|||
try {
|
||||
global $pdo;
|
||||
|
||||
$db_version = "01072021_0630";
|
||||
$db_version = "23082021_2224";
|
||||
|
||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
|
@ -632,6 +632,8 @@ function init_db_schema() {
|
|||
"is_running" => "TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
"returned_text" => "LONGTEXT",
|
||||
"last_run" => "TIMESTAMP NULL DEFAULT NULL",
|
||||
"success" => "TINYINT(1) UNSIGNED DEFAULT NULL",
|
||||
"exit_status" => "VARCHAR(50) DEFAULT NULL",
|
||||
"created" => "DATETIME(0) NOT NULL DEFAULT NOW(0)",
|
||||
"modified" => "DATETIME ON UPDATE CURRENT_TIMESTAMP",
|
||||
"active" => "TINYINT(1) NOT NULL DEFAULT '0'"
|
||||
|
|
|
@ -988,6 +988,7 @@ jQuery(function($){
|
|||
{"name":"exclude","title":lang.excludes,"breakpoints":"all"},
|
||||
{"name":"mins_interval","title":lang.mins_interval,"breakpoints":"all"},
|
||||
{"name":"last_run","title":lang.last_run,"breakpoints":"xs sm md"},
|
||||
{"name":"exit_status","filterable": false,"title":lang.syncjob_last_run_result},
|
||||
{"name":"log","title":"Log"},
|
||||
{"name":"active","filterable": false,"style":{"min-width":"70px","width":"70px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
|
||||
{"name":"is_running","filterable": false,"style":{"min-width":"120px","width":"100px"},"title":lang.status},
|
||||
|
@ -1024,6 +1025,18 @@ jQuery(function($){
|
|||
if (!item.last_run > 0) {
|
||||
item.last_run = lang.waiting;
|
||||
}
|
||||
if (item.success == null) {
|
||||
item.success = '-';
|
||||
item.exit_status = '';
|
||||
} else {
|
||||
item.success = '<i class="text-' + (item.success == 1 ? 'success' : 'danger') + ' bi bi-' + (item.success == 1 ? 'check-lg' : 'x-lg') + '"></i>';
|
||||
}
|
||||
if (lang['syncjob_'+item.exit_status]) {
|
||||
item.exit_status = lang['syncjob_'+item.exit_status];
|
||||
} else if (item.success != '-') {
|
||||
item.exit_status = lang.syncjob_check_log;
|
||||
}
|
||||
item.exit_status = item.success + ' ' + item.exit_status;
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
|
|
@ -176,12 +176,13 @@ jQuery(function($){
|
|||
"columns": [
|
||||
{"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px","text-align":"center"},"filterable": false,"sortable": false,"type":"html"},
|
||||
{"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
|
||||
{"name":"server_w_port","title":"Server"},
|
||||
{"name":"server_w_port","title":"Server","breakpoints":"xs sm md","style":{"word-break":"break-all"}},
|
||||
{"name":"enc1","title":lang.encryption,"breakpoints":"all"},
|
||||
{"name":"user1","title":lang.username},
|
||||
{"name":"exclude","title":lang.excludes,"breakpoints":"all"},
|
||||
{"name":"mins_interval","title":lang.interval + " (min)","breakpoints":"all"},
|
||||
{"name":"last_run","title":lang.last_run,"breakpoints":"all"},
|
||||
{"name":"last_run","title":lang.last_run,"breakpoints":"xs sm md"},
|
||||
{"name":"exit_status","filterable": false,"title":lang.syncjob_last_run_result},
|
||||
{"name":"log","title":"Log"},
|
||||
{"name":"active","filterable": false,"style":{"maxWidth":"70px","width":"70px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
|
||||
{"name":"is_running","filterable": false,"style":{"maxWidth":"120px","width":"100px"},"title":lang.status},
|
||||
|
@ -224,6 +225,18 @@ jQuery(function($){
|
|||
if (!item.last_run > 0) {
|
||||
item.last_run = lang.waiting;
|
||||
}
|
||||
if (item.success == null) {
|
||||
item.success = '-';
|
||||
item.exit_status = '';
|
||||
} else {
|
||||
item.success = '<i class="text-' + (item.success == 1 ? 'success' : 'danger') + ' bi bi-' + (item.success == 1 ? 'check-lg' : 'x-lg') + '"></i>';
|
||||
}
|
||||
if (lang['syncjob_'+item.exit_status]) {
|
||||
item.exit_status = lang['syncjob_'+item.exit_status];
|
||||
} else if (item.success != '-') {
|
||||
item.exit_status = lang.syncjob_check_log;
|
||||
}
|
||||
item.exit_status = item.success + ' ' + item.exit_status;
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
|
|
@ -794,6 +794,15 @@
|
|||
"stats": "Statistika",
|
||||
"status": "Stav",
|
||||
"sync_jobs": "Synchronizační úlohy",
|
||||
"syncjob_check_log": "Zkontrolujte záznam",
|
||||
"syncjob_last_run_result": "Výsledek posledního spuštění",
|
||||
"syncjob_EX_OK": "Úspěch",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE": "Problém se spojením",
|
||||
"syncjob_EXIT_TLS_FAILURE": "Problém se šifrovaným spojením",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE": "Problém s autentifikací",
|
||||
"syncjob_EXIT_OVERQUOTA": "Cílová schránka je plná",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE_HOST1": "Nelze se připojit ke vzdálenému serveru",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE_USER1": "Chybné uživatelské jméno nebo heslo",
|
||||
"table_size": "Velikost tabulky",
|
||||
"table_size_show_n": "Zobrazit %s položek",
|
||||
"target_address": "Cílová adresa",
|
||||
|
@ -1119,6 +1128,15 @@
|
|||
"spamfilter_yellow": "Žlutá: tato zpráva může být spam, bude označena jako spam a přesunuta do složky nevyžádané pošty",
|
||||
"status": "Stav",
|
||||
"sync_jobs": "Synchronizační úlohy",
|
||||
"syncjob_check_log": "Zkontrolujte záznam",
|
||||
"syncjob_last_run_result": "Výsledek posledního spuštění",
|
||||
"syncjob_EX_OK": "Úspěch",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE": "Problém se spojením",
|
||||
"syncjob_EXIT_TLS_FAILURE": "Problém se šifrovaným spojením",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE": "Problém s autentifikací",
|
||||
"syncjob_EXIT_OVERQUOTA": "Cílová schránka je plná",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE_HOST1": "Nelze se připojit ke vzdálenému serveru",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE_USER1": "Chybné uživatelské jméno nebo heslo",
|
||||
"tag_handling": "Zacházení s označkovanou poštou",
|
||||
"tag_help_example": "Příklad e-mailové adresy se značkou: me<b>+Facebook</b>@example.org",
|
||||
"tag_help_explain": "V podsložce: v doručené poště bude vytvořena nová podsložka pojmenovaná po značce zprávy (\"INBOX / Facebook\").<br>\r\nV předmětu: název značky bude přidáván k předmětu mailu, například: \"[Facebook] Moje zprávy\".",
|
||||
|
|
|
@ -820,6 +820,15 @@
|
|||
"stats": "Statistics",
|
||||
"status": "Status",
|
||||
"sync_jobs": "Sync jobs",
|
||||
"syncjob_check_log": "Check log",
|
||||
"syncjob_last_run_result": "Last run result",
|
||||
"syncjob_EX_OK": "Success",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE": "Connection problem",
|
||||
"syncjob_EXIT_TLS_FAILURE": "Problem with encrypted connection",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE": "Authentication problem",
|
||||
"syncjob_EXIT_OVERQUOTA": "Target mailbox is over quota",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE_HOST1": "Can't connect to remote server",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE_USER1": "Wrong username or password",
|
||||
"table_size": "Table size",
|
||||
"table_size_show_n": "Show %s items",
|
||||
"target_address": "Goto address",
|
||||
|
@ -1147,6 +1156,15 @@
|
|||
"spamfilter_yellow": "Yellow: this message may be spam, will be tagged as spam and moved to your junk folder",
|
||||
"status": "Status",
|
||||
"sync_jobs": "Sync jobs",
|
||||
"syncjob_check_log": "Check log",
|
||||
"syncjob_last_run_result": "Last run result",
|
||||
"syncjob_EX_OK": "Success",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE": "Connection problem",
|
||||
"syncjob_EXIT_TLS_FAILURE": "Problem with encrypted connection",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE": "Authentication problem",
|
||||
"syncjob_EXIT_OVERQUOTA": "Target mailbox is over quota",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE_HOST1": "Can't connect to remote server",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE_USER1": "Wrong username or password",
|
||||
"tag_handling": "Set handling for tagged mail",
|
||||
"tag_help_example": "Example for a tagged email address: me<b>+Facebook</b>@example.org",
|
||||
"tag_help_explain": "In subfolder: a new subfolder named after the tag will be created below INBOX (\"INBOX/Facebook\").<br>\r\nIn subject: the tags name will be prepended to the mails subject, example: \"[Facebook] My News\".",
|
||||
|
|
|
@ -818,6 +818,15 @@
|
|||
"stats": "Štatistika",
|
||||
"status": "Status",
|
||||
"sync_jobs": "Synchronizačné úlohy",
|
||||
"syncjob_check_log": "Skontrolujte záznam",
|
||||
"syncjob_last_run_result": "Výsledok posledného spustenia",
|
||||
"syncjob_EX_OK": "Úspech",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE": "Problém so spojením",
|
||||
"syncjob_EXIT_TLS_FAILURE": "Problém so šifrovaným spojením",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE": "Problém s autentifikáciou",
|
||||
"syncjob_EXIT_OVERQUOTA": "Cieľová schránka je plná",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE_HOST1": "Nedá sa pripojiť k vzdialenému serveru",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE_USER1": "Chybné uživateľské meno alebo heslo",
|
||||
"table_size": "Veľkosť tabuľky",
|
||||
"table_size_show_n": "Zobraziť %s položiek",
|
||||
"target_address": "Cieľová adresa",
|
||||
|
@ -1145,6 +1154,15 @@
|
|||
"spamfilter_yellow": "Žltá: Táto správa môže byť spam, bude označená ako spam a presunutá do priečinku nevyžiadanej pošty",
|
||||
"status": "Status",
|
||||
"sync_jobs": "Synchronizačné úlohy",
|
||||
"syncjob_check_log": "Skontrolujte záznam",
|
||||
"syncjob_last_run_result": "Výsledok posledného spustenia",
|
||||
"syncjob_EX_OK": "Úspech",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE": "Problém so spojením",
|
||||
"syncjob_EXIT_TLS_FAILURE": "Problém so šifrovaným spojením",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE": "Problém s autentifikáciou",
|
||||
"syncjob_EXIT_OVERQUOTA": "Cieľová schránka je plná",
|
||||
"syncjob_EXIT_CONNECTION_FAILURE_HOST1": "Nedá sa pripojiť k vzdialenému serveru",
|
||||
"syncjob_EXIT_AUTHENTICATION_FAILURE_USER1": "Chybné uživateľské meno alebo heslo",
|
||||
"tag_handling": "Zaobchádzanie s označenou poštou",
|
||||
"tag_help_example": "Príklad tagu e-mailovej adresy: me<b>+Facebook</b>@example.org",
|
||||
"tag_help_explain": "V podadresári: nový podadresár s menom tag-u bude vytvorený nižšie INBOX (\"INBOX/Facebook\").<br>\r\nIn subject: meno štítka bude pridané pred predmet pošty, napríklad: \"[Facebook] My News\".",
|
||||
|
|
|
@ -385,7 +385,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
|||
<a class="btn btn-sm btn-xs-half visible-xs-block visible-sm-inline visible-md-inline visible-lg-inline btn-default" id="toggle_multi_select_all" data-id="syncjob" href="#"><i class="bi bi-check-all"></i> <?=$lang['mailbox']['toggle_all'];?></a>
|
||||
<a class="btn btn-sm btn-xs-half visible-xs-block visible-sm-inline visible-md-inline visible-lg-inline btn-default dropdown-toggle" data-toggle="dropdown" href="#"><?=$lang['mailbox']['quick_actions'];?> <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a data-action="edit_selected" data-id="syncjob" data-api-url='edit/syncjob' data-api-attr='{"last_run":""}' href="#"><?=$lang['mailbox']['last_run_reset'];?></a></li>
|
||||
<li><a data-action="edit_selected" data-id="syncjob" data-api-url='edit/syncjob' data-api-attr='{"last_run":"","success":""}' href="#"><?=$lang['mailbox']['last_run_reset'];?></a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a data-action="edit_selected" data-id="syncjob" data-api-url='edit/syncjob' data-api-attr='{"active":"1"}' href="#"><?=$lang['mailbox']['activate'];?></a></li>
|
||||
<li><a data-action="edit_selected" data-id="syncjob" data-api-url='edit/syncjob' data-api-attr='{"active":"0"}' href="#"><?=$lang['mailbox']['deactivate'];?></a></li>
|
||||
|
|
|
@ -210,7 +210,7 @@ services:
|
|||
- sogo
|
||||
|
||||
dovecot-mailcow:
|
||||
image: mailcow/dovecot:1.155
|
||||
image: mailcow/dovecot:1.156
|
||||
depends_on:
|
||||
- mysql-mailcow
|
||||
dns:
|
||||
|
|
Loading…
Reference in New Issue