diff --git a/Dockerfile b/Dockerfile index ec7fb500..c9a8d739 100755 --- a/Dockerfile +++ b/Dockerfile @@ -43,12 +43,17 @@ RUN apk update --no-cache \ && apk add --no-cache curl arp-scan iproute2 iproute2-ss nmap nmap-scripts traceroute net-tools net-snmp-tools bind-tools awake ca-certificates \ && apk add --no-cache sqlite php83 php83-fpm php83-cgi php83-curl php83-sqlite3 php83-session \ && apk add --no-cache python3 nginx \ + && apk add --no-cache dcron \ && ln -s /usr/bin/awake /usr/bin/wakeonlan \ && bash -c "install -d -m 750 -o nginx -g www-data ${INSTALL_DIR} ${INSTALL_DIR}" \ && rm -f /etc/nginx/http.d/default.conf COPY --from=builder --chown=nginx:www-data ${INSTALL_DIR}/ ${INSTALL_DIR}/ +# Add crontab file +COPY install/crontab /etc/crontabs/root + +# Start all required services RUN ${INSTALL_DIR}/dockerfiles/pre-setup.sh HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=2 \ diff --git a/back/cron_script.sh b/back/cron_script.sh new file mode 100755 index 00000000..a9c2e3d4 --- /dev/null +++ b/back/cron_script.sh @@ -0,0 +1,13 @@ +#!/bin/bash +export INSTALL_DIR=/app + +LOG_FILE="${INSTALL_DIR}/front/log/execution_queue.log" + +# Check if there are any entries with cron_restart_backend +if grep -q "cron_restart_backend" "$LOG_FILE"; then + # Kill all python processes and restart the server + pkill -f "python " && (python ${INSTALL_DIR}/server > /dev/null 2>&1 &) && echo 'done' + + # Remove all lines containing cron_restart_backend from the log file + sed -i '/cron_restart_backend/d' "$LOG_FILE" +fi diff --git a/dockerfiles/pre-setup.sh b/dockerfiles/pre-setup.sh index 551c09f9..fcc35bac 100755 --- a/dockerfiles/pre-setup.sh +++ b/dockerfiles/pre-setup.sh @@ -38,4 +38,6 @@ touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx,$APP_N touch /etc/s6-overlay/s6-rc.d/nginx/dependencies.d/php-fpm touch /etc/s6-overlay/s6-rc.d/$APP_NAME/dependencies.d/nginx + + rm -f $0 diff --git a/dockerfiles/setup.sh b/dockerfiles/setup.sh index 4ee486c3..1b3e50f5 100755 --- a/dockerfiles/setup.sh +++ b/dockerfiles/setup.sh @@ -109,6 +109,10 @@ if [ ! -f "${INSTALL_DIR}/front/buildtimestamp.txt" ]; then chown nginx:www-data "${INSTALL_DIR}/front/buildtimestamp.txt" fi +# Start crond service in the background +echo "[INSTALL] Starting crond service..." +crond -f -d 8 > /dev/null 2>&1 & + echo -e " [ENV] PATH is ${PATH} [ENV] PORT is ${PORT} diff --git a/front/css/app.css b/front/css/app.css index abfae4b2..dea0ce5c 100755 --- a/front/css/app.css +++ b/front/css/app.css @@ -27,11 +27,17 @@ font-family: 'Courier New', monospace; } +.logs-row textarea +{ + width: 100%; +} +.logs-row button{ + margin: 2px; +} .logs-row { align-content: center; width: 100%; - display: grid; margin: 5px; } .logs-size @@ -52,8 +58,7 @@ } .log-file { - width: 145px; - display: inline-grid; + font-size: 20px; } .log-purge diff --git a/front/devices.php b/front/devices.php index 4995e130..f5e8001a 100755 --- a/front/devices.php +++ b/front/devices.php @@ -336,6 +336,7 @@ function getDevicesTotals(devicesData) { } //------------------------------------------------------------------------------ +// Render the info boxes/tiles on top function renderInfoboxes(customData) { $.ajax({ url: 'php/components/tile_cards.php', // PHP script URL diff --git a/front/help_faq.php b/front/help_faq.php index 456ad0b3..c212e003 100755 --- a/front/help_faq.php +++ b/front/help_faq.php @@ -147,19 +147,6 @@ -
-
-

- - "" -

-
-
-
- -
-
-

diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js index 77627a77..4b903728 100755 --- a/front/js/settings_utils.js +++ b/front/js/settings_utils.js @@ -412,58 +412,6 @@ function filterRows(inputText) { - // ----------------------------------------------------------------------------- - // handling events on the backend initiated by the front end START - // ----------------------------------------------------------------------------- - - modalEventStatusId = 'modal-message-front-event' - - // -------------------------------------------------------- - // Calls a backend function to add a front-end event (specified by the attributes 'data-myevent' and 'data-myparam-plugin' on the passed element) to an execution queue - function addToExecutionQueue(element) - { - - // value has to be in format event|param. e.g. run|ARPSCAN - action = `${getGuid()}|${$(element).attr('data-myevent')}|${$(element).attr('data-myparam-plugin')}` - - $.ajax({ - method: "POST", - url: "php/server/util.php", - data: { function: "addToExecutionQueue", action: action }, - success: function(data, textStatus) { - // showModalOk ('Result', data ); - - // show message - showModalOk(getString("general_event_title"), `${getString("general_event_description")}

`); - - updateModalState() - } - }) - } - - // -------------------------------------------------------- - // Updating the execution queue in in modal pop-up - function updateModalState() { - setTimeout(function() { - // Fetch the content from the log file using an AJAX request - $.ajax({ - url: '/log/execution_queue.log', - type: 'GET', - success: function(data) { - // Update the content of the HTML element (e.g., a div with id 'logContent') - $('#'+modalEventStatusId).html(data); - - updateModalState(); - }, - error: function() { - // Handle error, such as the file not being found - $('#logContent').html('Error: Log file not found.'); - } - }); - }, 2000); - } - - // ----------------------------------------------------------------------------- // handling events on the backend initiated by the front end END // ----------------------------------------------------------------------------- diff --git a/front/js/ui_components.js b/front/js/ui_components.js index 20da9d48..518bf587 100755 --- a/front/js/ui_components.js +++ b/front/js/ui_components.js @@ -306,6 +306,57 @@ function getCellValue(row, index) { return $(row).children('td').eq(index).text(); } + // ----------------------------------------------------------------------------- + // handling events on the backend initiated by the front end START + // ----------------------------------------------------------------------------- + + modalEventStatusId = 'modal-message-front-event' + + // -------------------------------------------------------- + // Calls a backend function to add a front-end event (specified by the attributes 'data-myevent' and 'data-myparam-plugin' on the passed element) to an execution queue + function addToExecutionQueue(element) + { + + // value has to be in format event|param. e.g. run|ARPSCAN + action = `${getGuid()}|${$(element).attr('data-myevent')}|${$(element).attr('data-myparam-plugin')}` + + $.ajax({ + method: "POST", + url: "php/server/util.php", + data: { function: "addToExecutionQueue", action: action }, + success: function(data, textStatus) { + // showModalOk ('Result', data ); + + // show message + showModalOk(getString("general_event_title"), `${getString("general_event_description")}

`); + + updateModalState() + } + }) + } + + // -------------------------------------------------------- + // Updating the execution queue in in modal pop-up + function updateModalState() { + setTimeout(function() { + // Fetch the content from the log file using an AJAX request + $.ajax({ + url: '/log/execution_queue.log', + type: 'GET', + success: function(data) { + // Update the content of the HTML element (e.g., a div with id 'logContent') + $('#'+modalEventStatusId).html(data); + + updateModalState(); + }, + error: function() { + // Handle error, such as the file not being found + $('#logContent').html('Error: Log file not found.'); + } + }); + }, 2000); + } + // ----------------------------------------------------------------------------- // initialize diff --git a/front/maintenance.php b/front/maintenance.php index af9021ae..25722ceb 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -405,112 +405,8 @@ $db->close();
-
-
- -
-
-
-
app.log
- -
- -
- - -
-
-
-
-
-
- -
-
-
-
app_front.log
- -
-
- -
-
-
-
-
-
- -
-
-
-
app.php_errors.log
- -
-
- -
-
-
-
-
-
- -
-
-
-
nginx/error.log
- -
-
-
-
-
- -
-
-
-
stdout.log
- -
-
- -
-
-
-
-
-
- -
-
-
-
stderr.log
- -
-
- -
-
-
- -
+
@@ -566,12 +462,14 @@ var selectedTab = 'tab_Settings_id'; initializeTabs(); +// ----------------------------------------------------------- // delete devices with emty macs function askDeleteDevicesWithEmptyMACs () { // Ask showModalWarning('', '', 'Cancel', 'Delete', 'deleteDevicesWithEmptyMACs'); } +// ----------------------------------------------------------- function deleteDevicesWithEmptyMACs() { // Delete device @@ -580,12 +478,14 @@ function deleteDevicesWithEmptyMACs() }); } +// ----------------------------------------------------------- // delete all devices function askDeleteAllDevices () { // Ask showModalWarning('', '', '', '', 'deleteAllDevices'); } +// ----------------------------------------------------------- function deleteAllDevices() { // Delete device @@ -594,12 +494,14 @@ function deleteAllDevices() }); } +// ----------------------------------------------------------- // delete all (unknown) devices function askDeleteUnknown () { // Ask showModalWarning('', '', '', '', 'deleteUnknownDevices'); } +// ----------------------------------------------------------- function deleteUnknownDevices() { // Execute @@ -608,12 +510,14 @@ function deleteUnknownDevices() }); } +// ----------------------------------------------------------- // delete all Events function askDeleteEvents () { // Ask showModalWarning('', '', '', '', 'deleteEvents'); } +// ----------------------------------------------------------- function deleteEvents() { // Execute @@ -622,12 +526,14 @@ function deleteEvents() }); } +// ----------------------------------------------------------- // delete all Events older than 30 days function askDeleteEvents30 () { // Ask showModalWarning('', '', '', '', 'deleteEvents30'); } +// ----------------------------------------------------------- function deleteEvents30() { // Execute @@ -636,6 +542,7 @@ function deleteEvents30() }); } +// ----------------------------------------------------------- // delete History function askDeleteActHistory () { // Ask @@ -650,6 +557,7 @@ function deleteActHistory() }); } +// ----------------------------------------------------------- // Backup DB to Archive function askPiaBackupDBtoArchive () { // Ask @@ -664,6 +572,7 @@ function PiaBackupDBtoArchive() }); } +// ----------------------------------------------------------- // Restore DB from Archive function askPiaRestoreDBfromArchive () { // Ask @@ -678,6 +587,7 @@ function PiaRestoreDBfromArchive() }); } +// ----------------------------------------------------------- // Purge Backups function askPiaPurgeDBBackups() { // Ask @@ -692,22 +602,37 @@ function PiaPurgeDBBackups() }); } -// Restart Backend -function restartBackend() { - // Execute - $.ajax({ - method: "POST", - url: "php/server/util.php", - data: { function: 'restartBackend' }, - success: function(data, textStatus) { - showModalOk ('Result', data ); - } - }) - - - +// ----------------------------------------------------------- +// Restart Backend Python Server + +function askRestartBackend() { + // Ask + showModalWarning('', '', + '', '', 'restartBackend'); } +// ----------------------------------------------------------- +function restartBackend() { + + modalEventStatusId = 'modal-message-front-event' + + // Execute + $.ajax({ + method: "POST", + url: "php/server/util.php", + data: { function: "addToExecutionQueue", action: 'cron_restart_backend' }, + success: function(data, textStatus) { + // showModalOk ('Result', data ); + + // show message + showModalOk(getString("general_event_title"), `${getString("general_event_description")}

`); + + updateModalState() + } + }) +} + +// ----------------------------------------------------------- // Export CSV function askExportCSV() { // Ask @@ -720,6 +645,7 @@ function ExportCSV() openInNewTab("php/server/devices.php?action=ExportCSV") } +// ----------------------------------------------------------- // Import CSV function askImportCSV() { // Ask @@ -952,13 +878,31 @@ function initializeTabs () { } +//------------------------------------------------------------------------------ +function renderLogs(customData) { + $.ajax({ + url: 'php/components/logs.php', // PHP script URL + type: 'POST', // Use POST method to send data + dataType: 'html', // Expect HTML response + // data: { items: JSON.stringify(customData) }, // Send customData as JSON + success: function(response) { + $('#logsPlc').html(response); // Replace container content with fetched HTML + }, + error: function(xhr, status, error) { + console.error('Error fetching infoboxes:', error); + } + }); + } -// load footer asynchronously not to block the page load/other sections + +// Init window.onload = function asyncFooter() { initializeSelectedColumns(); - scrollDown(); - initializeTabs(); + renderLogs(); + scrollDown(); // scroll down the logs + + // initializeTabs(); $("#lastCommit").append('GitHub last commit'); @@ -967,10 +911,6 @@ window.onload = function asyncFooter() } -// scroll to the latest log entrie sat teh bottom of the file - - - diff --git a/front/php/components/logs.php b/front/php/components/logs.php new file mode 100755 index 00000000..a989226c --- /dev/null +++ b/front/php/components/logs.php @@ -0,0 +1,76 @@ + 2000000) { + $content = file_get_contents($filePath, false, null, -2000000); + } else { + $content = file_get_contents($filePath); + } + + // Render the log area HTML + $html = ' +
+
+ +
+
+
' . $fileName . ' +
' . number_format((filesize($filePath) / 1000000), 2, ",", ".") . ' MB + +
+
+
+ '; + + // Render each button + foreach ($buttons as $button) { + $labelStringCode = isset($button['labelStringCode']) ? $button['labelStringCode'] : ''; + $event = isset($button['event']) ? $button['event'] : ''; + + $html .= ' +
+ +
+ '; + } + + $html .= ' +
+
+
+ '; + + return $html; +} + +// Load default data from JSON file +$defaultDataFile = 'logs_defaults.json'; +$defaultData = file_exists($defaultDataFile) ? json_decode(file_get_contents($defaultDataFile), true) : []; + +// Check if JSON data is submitted via POST +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['items'])) { + $items = json_decode($_POST['items'], true); +} else { + $items = $defaultData; +} + +// Render the log areas with the retrieved or default data +$html = ''; +foreach ($items as $item) { + $html .= renderLogArea($item); +} + +echo $html; +exit(); +?> diff --git a/front/php/components/logs_defaults.json b/front/php/components/logs_defaults.json new file mode 100755 index 00000000..ca1537b0 --- /dev/null +++ b/front/php/components/logs_defaults.json @@ -0,0 +1,80 @@ +[ + { + "buttons": [ + { + "labelStringCode": "Maint_PurgeLog", + "event": "logManage('app.log', 'cleanLog')" + }, + { + "labelStringCode": "Maint_RestartServer", + "event": "askRestartBackend()" + } + ], + "fileName": "app.log", + "filePath": "/app/front/log/app.log", + "textAreaCssClass": "logs" + + }, + { + "buttons": [ + { + "labelStringCode": "Maint_PurgeLog", + "event": "logManage('app_front.log', 'cleanLog')" + } + ], + "fileName": "app_front.log", + "filePath": "/app/front/log/app_front.log", + "textAreaCssClass": "logs logs-small" + }, + { + "buttons": [ + { + "labelStringCode": "Maint_PurgeLog", + "event": "logManage('app.php_errors.log', 'cleanLog')" + } + ], + "fileName": "app.php_errors.log", + "filePath": "/app/front/log/app.php_errors.log", + "textAreaCssClass": "logs logs-small" + }, + { + "buttons": [ + ], + "fileName": "nginx/error.log", + "filePath": "/var/log/nginx/error.log", + "textAreaCssClass": "logs logs-small" + }, + { + "buttons": [ + { + "labelStringCode": "Maint_PurgeLog", + "event": "logManage('app_front.log', 'cleanLog')" + } + ], + "fileName": "app_front.log", + "filePath": "/app/front/log/app_front.log", + "textAreaCssClass": "logs logs-small" + }, + { + "buttons": [ + { + "labelStringCode": "Maint_PurgeLog", + "event": "logManage('stdout.log', 'cleanLog')" + } + ], + "fileName": "stdout.log", + "filePath": "/app/front/log/stdout.log", + "textAreaCssClass": "logs logs-small" + }, + { + "buttons": [ + { + "labelStringCode": "Maint_PurgeLog", + "event": "logManage('stderr.log', 'cleanLog')" + } + ], + "fileName": "stderr.log", + "filePath": "/app/front/log/stderr.log", + "textAreaCssClass": "logs logs-small" + } +] \ No newline at end of file diff --git a/front/php/server/util.php b/front/php/server/util.php index 83c42b63..1c9ed559 100755 --- a/front/php/server/util.php +++ b/front/php/server/util.php @@ -28,10 +28,7 @@ if(array_key_exists('settings', $_REQUEST) != FALSE) // call functions based on requested params switch ($FUNCTION) { - case 'restartBackend': - - restartBackend(); - break; + case 'savesettings': saveSettings(); @@ -228,6 +225,7 @@ function displayMessage($message, $logAlert = FALSE, $logConsole = TRUE, $logFil } +// ---------------------------------------------------------------------------------------- // Adds an action to perform into the execution_queue.log file function addToExecutionQueue($action) { @@ -247,27 +245,6 @@ function addToExecutionQueue($action) } -// ---------------------------------------------------------------------------------------- -function restartBackend() -{ - $command = 'pkill -f "python /app/server" && (python /app/server > /dev/null 2>&1 &) && echo "done" 2>&1'; - - // Execute the command - $output = []; - $output_str = ""; - $return_var = 0; - exec($command, $output, $return_var); - - // Format the output - foreach ($output as $line) { - $output_str .= $line . "\n"; - } - - - echo "Command result: $return_var, $output_str"; - -} - // ---------------------------------------------------------------------------------------- function cleanLog($logFile) diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index 000e7b34..6233b592 100755 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -384,6 +384,9 @@ "MQTT_USER_name": "MQTT user", "MQTT_display_name": "MQTT", "MQTT_icon": "", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "Installierte Version", "Maintenance_Status": "Status", "Maintenance_Title": "Wartungswerkzeuge", diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 03f7cb1a..3e3d1bd9 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "Password Alert!", "Login_Toggle_Info": "Password Information", "Login_Toggle_Info_headline": "Password Information", + "Maint_PurgeLog": "Purge log", + "Maint_RestartServer": "Restart server", + "Maint_Restart_Server_noti_text": "Are you sure you want to restart the backend server? This may casue app inconsistency. Backup your setup first.

Note: This may take a few minutes.", "Maintenance_Running_Version": "Installed version", "Maintenance_Status": "Status", "Maintenance_Title": "Maintenance tools", diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index 94fd3a69..bf4690d8 100755 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -382,6 +382,9 @@ "MQTT_USER_name": "Usuario de MQTT", "MQTT_display_name": "MQTT", "MQTT_icon": "", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "Versión instalada", "Maintenance_Status": "Situación", "Maintenance_Title": "Herramientas de mantenimiento", diff --git a/front/php/templates/language/fr_fr.json b/front/php/templates/language/fr_fr.json index bb02f339..e6f10c71 100755 --- a/front/php/templates/language/fr_fr.json +++ b/front/php/templates/language/fr_fr.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "", "Login_Toggle_Info": "", "Login_Toggle_Info_headline": "", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "Version installée", "Maintenance_Status": "État", "Maintenance_Title": "Outils d'entretien", @@ -684,4 +687,4 @@ "settings_update_item_warning": "", "test_event_icon": "", "test_event_tooltip": "" -} +} \ No newline at end of file diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json index 83b2de6c..5fcff32c 100755 --- a/front/php/templates/language/it_it.json +++ b/front/php/templates/language/it_it.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "Avviso password!", "Login_Toggle_Info": "Informazioni password", "Login_Toggle_Info_headline": "Informazioni password", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "Versione installata", "Maintenance_Status": "Stato", "Maintenance_Title": "Strumenti di manutenzione", @@ -684,4 +687,4 @@ "settings_update_item_warning": "Aggiorna il valore qui sotto. Fai attenzione a seguire il formato precedente. La convalida non viene eseguita.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Salva le modifiche prima di provare le nuove impostazioni." -} +} \ No newline at end of file diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json index 6292f818..2d7649fe 100755 --- a/front/php/templates/language/nb_no.json +++ b/front/php/templates/language/nb_no.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "Passord Varsling!", "Login_Toggle_Info": "Passordinformasjon", "Login_Toggle_Info_headline": "Passordinformasjon", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "Installert versjon", "Maintenance_Status": "Status", "Maintenance_Title": "Vedlikeholdsverktøy", diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json index bd8ec834..b469c3ea 100755 --- a/front/php/templates/language/pl_pl.json +++ b/front/php/templates/language/pl_pl.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "Alert Hasła!", "Login_Toggle_Info": "Informacje o haśle", "Login_Toggle_Info_headline": "Informacje o haśle", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "Zainstalowana wersja", "Maintenance_Status": "Status", "Maintenance_Title": "Narzędzia konserwacyjne", diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json index df3220cd..3fc7127e 100755 --- a/front/php/templates/language/pt_br.json +++ b/front/php/templates/language/pt_br.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "", "Login_Toggle_Info": "", "Login_Toggle_Info_headline": "", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "", "Maintenance_Status": "", "Maintenance_Title": "", diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json old mode 100644 new mode 100755 index dc13487c..2b315a48 --- a/front/php/templates/language/ru_ru.json +++ b/front/php/templates/language/ru_ru.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "Предупреждение о пароле!", "Login_Toggle_Info": "Информация о пароле", "Login_Toggle_Info_headline": "Информация о пароле", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "Установленная версия", "Maintenance_Status": "Статус", "Maintenance_Title": "Инструменты обслуживания", @@ -684,4 +687,4 @@ "settings_update_item_warning": "Обновить значение ниже. Будьте осторожны, следуя предыдущему формату. Проверка не выполняется.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Сначала сохраните изменения, прежде чем проверять настройки." -} +} \ No newline at end of file diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json index 96f7fe56..03a67f43 100755 --- a/front/php/templates/language/tr_tr.json +++ b/front/php/templates/language/tr_tr.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "", "Login_Toggle_Info": "", "Login_Toggle_Info_headline": "", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "", "Maintenance_Status": "", "Maintenance_Title": "", diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json index 46f6d1b3..24ba6163 100755 --- a/front/php/templates/language/zh_cn.json +++ b/front/php/templates/language/zh_cn.json @@ -358,6 +358,9 @@ "Login_Toggle_Alert_headline": "", "Login_Toggle_Info": "", "Login_Toggle_Info_headline": "", + "Maint_PurgeLog": "", + "Maint_RestartServer": "", + "Maint_Restart_Server_noti_text": "", "Maintenance_Running_Version": "", "Maintenance_Status": "", "Maintenance_Title": "", diff --git a/install/crontab b/install/crontab new file mode 100755 index 00000000..a9fca9dd --- /dev/null +++ b/install/crontab @@ -0,0 +1,5 @@ + + +# Schedule cron jobs +* * * * * /app/back/cron_script.sh +* * * * * echo "$(date +'%Y-%m-%d %H:%M:%S') - Cron job ran" >> /app/front/log/cron_timestamp.log diff --git a/server/plugin.py b/server/plugin.py index 713c31a6..1b02c3a7 100755 --- a/server/plugin.py +++ b/server/plugin.py @@ -752,20 +752,24 @@ def check_and_run_user_event(db, all_plugins, pluginsState): # Check if the log file exists logFile = os.path.join(logPath, "execution_queue.log") - # track if not an API event + # Track if not an API event and list of executed events show_events_completed = False - + executed_events = [] + if not os.path.exists(logFile): return pluginsState with open(logFile, "r") as file: lines = file.readlines() + remaining_lines = [] + for line in lines: # Split the line by '|', and take the third and fourth columns (indices 2 and 3) columns = line.strip().split('|')[2:4] if len(columns) != 2: + remaining_lines.append(line) continue event, param = columns @@ -773,19 +777,26 @@ def check_and_run_user_event(db, all_plugins, pluginsState): if event == 'test': show_events_completed = True pluginsState = handle_test(param, db, all_plugins, pluginsState) - if event == 'run': + executed_events.append(f"test with param {param}") + elif event == 'run': show_events_completed = True pluginsState = handle_run(param, db, all_plugins, pluginsState) - if event == 'update_api': - # update API endpoints - update_api(db, all_plugins, False, param.split(',')) + executed_events.append(f"run with param {param}") + elif event == 'update_api': + # Update API endpoints + update_api(db, all_plugins, False, param.split(',')) + executed_events.append(f"update_api with param {param}") + else: + remaining_lines.append(line) - # Clear the log file - open(logFile, "w").close() + # Rewrite the log file with remaining lines + with open(logFile, "w") as file: + file.writelines(remaining_lines) - # only show pop up if not an API event + # Only show pop-up if not an API event if show_events_completed: - write_notification('[Ad-hoc events] All Events executed', 'interrupt', timeNowTZ()) + executed_events_message = ', '.join(executed_events) + write_notification(f'[Ad-hoc events] Events executed: {executed_events_message}', 'interrupt', timeNowTZ()) return pluginsState