From 2824c89d293329045fec35460210e80caac539d8 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 17 Oct 2024 20:22:51 +0200 Subject: [PATCH 1/9] #346 unify cron scripts --- lam/lib/cronGlobal.inc | 77 +++++-------- lam/lib/cronRunner.inc | 246 ++++++++++++++++++++++++++++++++++++++++ lam/lib/runCronJobs.inc | 95 ++++++++++++++++ lam/lib/runCronJobs.sh | 13 +++ 4 files changed, 381 insertions(+), 50 deletions(-) create mode 100644 lam/lib/cronRunner.inc create mode 100644 lam/lib/runCronJobs.inc create mode 100755 lam/lib/runCronJobs.sh diff --git a/lam/lib/cronGlobal.inc b/lam/lib/cronGlobal.inc index 795fd13b2..3f7f76ae0 100644 --- a/lam/lib/cronGlobal.inc +++ b/lam/lib/cronGlobal.inc @@ -2,23 +2,29 @@ namespace LAM\Cron; -use Exception; -use LAM\DB\CronDatabase; -use LAMCfgMain; -use LAMConfig; -use LAMException; -use PDOException; -use Ldap; -use LAM\JOB\JobResultLog; -use ServerProfilePersistenceManager; - /* - This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2024 Roland Gruber + This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) + Copyright (C) 2024 Roland Gruber + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +use LAMException; + /** * Global cron job for LAM. * @@ -26,46 +32,17 @@ use ServerProfilePersistenceManager; * @author Roland Gruber */ -/** access to configuration data */ -include_once(__DIR__ . "/config.inc"); -/** access to ldap data */ -include_once(__DIR__ . "/ldap.inc"); -/** access to modules */ -include_once(__DIR__ . "/modules.inc"); +/** cron runner */ +include_once(__DIR__ . "/cronRunner.inc"); // check parameters -$isDryRun = (isset($argv[2]) && ($argv[2] == '--dryRun')) ? true : false; - -$_SESSION['cfgMain'] = new LAMCfgMain(); - -if ($isDryRun) { - echo "Dry run: no changes, only logging.\n"; -} +$isDryRun = isset($argv[2]) && ($argv[2] === '--dryRun'); -// execute jobs -$errorsOccurred = false; -$allModules = getAllModules(); -foreach ($allModules as $module) { - if (!$module->supportsGlobalCronJob()) { - continue; - } - try { - if ($isDryRun) { - echo "Started actions for " . $module->get_alias() . "\n"; - } - logNewMessage(LOG_NOTICE, 'Started actions for ' . $module->get_alias()); - $module->runGlobalCronActions($isDryRun); - if ($isDryRun) { - echo "Finished actions for " . $module->get_alias() . "\n"; - } - logNewMessage(LOG_NOTICE, 'Finished actions for ' . $module->get_alias()); - } - catch (Exception $e) { - $errorsOccurred = true; - echo "Error in " . $module->get_alias() . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n"; - } +$cronRunner = new CronRunner($isDryRun); +try { + $cronRunner->runGlobalCronJobs(); } -if ($errorsOccurred) { - echo "Problems occurred during cron execution\n"; - die(1); +catch (LAMException $e) { + echo escapeshellcmd($e->getTitle()) . "\n"; + exit(1); } diff --git a/lam/lib/cronRunner.inc b/lam/lib/cronRunner.inc new file mode 100644 index 000000000..701c5627f --- /dev/null +++ b/lam/lib/cronRunner.inc @@ -0,0 +1,246 @@ +isDryRun = $isDryRun; + if ($isDryRun) { + echo "Dry run: no changes, only logging.\n"; + } + $_SESSION['cfgMain'] = new LAMCfgMain(); + // set certificates variables + setSSLCaCert(); + } + + /** + * Runs all global cron actions. + * @throws LAMException error running actions + */ + public function runGlobalCronJobs(): void { + if ($this->isDryRun) { + echo "Global actions started\n\n"; + } + $errorsOccurred = false; + $allModules = getAllModules(); + foreach ($allModules as $module) { + if (!$module->supportsGlobalCronJob()) { + continue; + } + try { + if ($this->isDryRun) { + echo "Started actions for " . $module->get_alias() . "\n"; + } + logNewMessage(LOG_NOTICE, 'Started actions for ' . $module->get_alias()); + $module->runGlobalCronActions($this->isDryRun); + if ($this->isDryRun) { + echo "Finished actions for " . $module->get_alias() . "\n"; + } + logNewMessage(LOG_NOTICE, 'Finished actions for ' . $module->get_alias()); + } + catch (Exception $e) { + $errorsOccurred = true; + echo "Error in " . $module->get_alias() . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n"; + } + } + if ($errorsOccurred) { + throw new LAMException("Problems occurred during cron execution"); + } + if ($this->isDryRun) { + echo "\nGlobal actions done\n\n"; + } + } + + /** + * Runs the actions of a single server profile. + * + * @param string $serverProfileName profile name + * @throws LAMException error running actions + */ + public function runSingleServerProfileActions(string $serverProfileName): void { + $serverProfilePersistenceManager = new ServerProfilePersistenceManager(); + $this->validateServerProfileName($serverProfileName, $serverProfilePersistenceManager); + if ($this->isDryRun) { + echo "Server profile started: " . $serverProfileName . "\n\n"; + } + + try { + $conf = $serverProfilePersistenceManager->loadProfile($serverProfileName); + $_SESSION['config'] = $conf; + } + catch (LAMException $e) { + echo $e->getTitle(); + exit(1); + } + + // test database connection + try { + $cronDatabase = new CronDatabase($conf); + $cronDatabase->connect(); + $pdo = $cronDatabase->getPdo(); + } + catch (PDOException $e) { + throw new LAMException("Unable to connect to database. " . $e->getMessage()); + } + catch (LAMException $e) { + throw new LAMException("Unable to connect to database. " . $e->getTitle()); + } + // get jobs to run + if (empty($cronDatabase->getJobs())) { + if ($this->isDryRun) { + echo "No jobs configured for " . $serverProfileName . "\n"; + } + return; + } + $this->openLdapConnection(); + if ($this->isDryRun) { + echo "\nServer profile done: " . $serverProfileName . "\n\n"; + } + $this->runServerProfileJobs($conf, $cronDatabase, $pdo, $serverProfileName); + } + + /** + * Validates the server profile. + * + * @param string $serverProfileName profile name + * @param ServerProfilePersistenceManager $serverProfilePersistenceManager persistence manager + * @throws LAMException invalid profile + */ + private function validateServerProfileName(string $serverProfileName, ServerProfilePersistenceManager $serverProfilePersistenceManager): void { + if (!LAMConfig::isValidName($serverProfileName)) { + throw new LAMException("Invalid config name: " . $serverProfileName); + } + $serverProfiles = []; + try { + $serverProfiles = $serverProfilePersistenceManager->getProfiles(); + } + catch (LAMException $e) { + logNewMessage(LOG_ERR, 'Unable to read server profiles: ' . $e->getTitle()); + } + if (!in_array($serverProfileName, $serverProfiles)) { + throw new LAMException("Config does not exist: " . $serverProfileName); + } + } + + /** + * Opens the LDAP connection. + * @throws LAMException unable to connect to LDAP + */ + private function openLdapConnection(): void { + $ldap = new Ldap($_SESSION['config']); + try { + $ldap->connect($_SESSION['config']->getJobsBindUser(), deobfuscateText($_SESSION['config']->getJobsBindPassword()), true); + } + catch (LAMException) { + throw new LAMException("Unable to connect to LDAP with error: " . ldap_error($ldap->server()) . "\n" . getExtendedLDAPErrorMessage($ldap->server())); + } + $_SESSION['ldap'] = $ldap; + } + + /** + * Runs the actions of a server profile. + * + * @param LAMConfig $conf config + * @param CronDatabase $cronDatabase cron DB + * @param PDO $pdo PDO + * @param string $serverProfileName server profile name + * @throws LAMException error executing job + */ + private function runServerProfileJobs(LAMConfig $conf, CronDatabase $cronDatabase, PDO $pdo, string $serverProfileName): void { + $errorsOccurred = false; + foreach ($cronDatabase->getJobs() as $jobId => $job) { + $resultLog = new JobResultLog(); + $jobName = $job->getName(); + try { + logNewMessage(LOG_NOTICE, 'Running job ' . $jobName . ' for server profile ' . $serverProfileName); + $resultLog->logInfo('Running job ' . $jobName . ' for server profile ' . $serverProfileName); + $job->execute($jobId, $conf->getJobSettings(), $pdo, $this->isDryRun, $resultLog); + if (!$this->isDryRun) { + if ($resultLog->hasError()) { + $cronDatabase->saveJobRun($jobName, $jobId, 1, implode("\n", $resultLog->getMessages())); + } + else { + $cronDatabase->saveJobRun($jobName, $jobId, 0, implode("\n", $resultLog->getMessages())); + } + } + else { + // for dry-run print messages to console + echo implode("\n", $resultLog->getMessages()) . "\n\n"; + } + logNewMessage(LOG_NOTICE, 'Finished job ' . $jobName . ' for server profile ' . $serverProfileName); + $resultLog->logInfo('Finished job ' . $jobName . ' for server profile ' . $serverProfileName); + } + catch (Exception $e) { + $errorsOccurred = true; + echo "Error in job " . $jobName . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n"; + if (!$this->isDryRun) { + $cronDatabase->saveJobRun($jobName, $jobId, 1, implode("\n", $resultLog->getMessages()) . "\n" . $e->getMessage()); + } + } + } + if ($errorsOccurred) { + throw new LAMException("Problems occurred during job execution for server profile " . $serverProfileName); + } + } + +} diff --git a/lam/lib/runCronJobs.inc b/lam/lib/runCronJobs.inc new file mode 100644 index 000000000..c350a55aa --- /dev/null +++ b/lam/lib/runCronJobs.inc @@ -0,0 +1,95 @@ +runGlobalCronJobs(); + } + catch (LAMException $e) { + echo escapeshellcmd($e->getTitle()) . "\n"; + exit(1); + } +} +elseif ($runSingleServerProfileActions && !empty($argv[3]) && LAMConfig::isValidName($argv[3])) { + try { + $cronRunner->runSingleServerProfileActions($argv[3]); + } + catch (LAMException $e) { + echo escapeshellcmd($e->getTitle()) . "\n"; + exit(1); + } +} +else { + echo "LAM - Run cron jobs\n" + . "\n" + . "Usage:\n" + . "\n" + . "Run all global cron jobs:\n" + . "\n" + . " runCronJobs.sh global\n" + . "\n" + . "Run all global cron jobs in dry-run:\n" + . "\n" + . " runCronJobs.sh global --dry-run\n" + . "\n" + . "Run cron jobs of a server profile:\n" + . "\n" + . " runCronJobs.sh serverProfile NAME\n" + . "\n" + . "Run cron jobs of a server profile in dry-run:\n" + . "\n" + . " runCronJobs.sh serverProfile NAME --dry-run\n" + . "\n" + . "Run cron jobs of all server profiles:\n" + . "\n" + . " runCronJobs.sh allServerProfiles\n" + . "\n" + . "Run cron jobs of all server profiles in dry-run:\n" + . "\n" + . " runCronJobs.sh allServerProfiles --dry-run\n" + . "\n" + . "\n"; +} diff --git a/lam/lib/runCronJobs.sh b/lam/lib/runCronJobs.sh new file mode 100755 index 000000000..013d6bf3a --- /dev/null +++ b/lam/lib/runCronJobs.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +dir=`dirname $0` + +if [ -x /usr/bin/php ]; then + # delimiter must be added to support arguments starting with "--" + /usr/bin/php -f $dir/runCronJobs.inc delimiter $* + exit $? +fi + +echo "No PHP executable found" + +exit 1 \ No newline at end of file From 667642f4ed46aacbc3b6e16963433e7867421f55 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 17 Oct 2024 20:26:28 +0200 Subject: [PATCH 2/9] #346 unify cron scripts --- lam/templates/config/mainmanage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lam/templates/config/mainmanage.php b/lam/templates/config/mainmanage.php index b1cb679d8..db76caef5 100644 --- a/lam/templates/config/mainmanage.php +++ b/lam/templates/config/mainmanage.php @@ -732,7 +732,7 @@ // global cron job if ($supportsGlobalCronJob) { $row->add(new htmlSubTitle(_('Global cron job'))); - $cronCommand = dirname(__FILE__, 3) . '/lib/cronGlobal.sh'; + $cronCommand = dirname(__FILE__, 3) . '/lib/runCronJobs.sh global'; $row->addLabel(new htmlOutputText('Cron command')); $cmdGroup = new htmlGroup(); $cmdGroup->addElement(new htmlOutputText('0 0 * * * ' . $cronCommand)); From 79dd327e0e399c1fdd4884fb318fb3f02025e5f0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 18 Oct 2024 07:50:01 +0200 Subject: [PATCH 3/9] #346 unify cron scripts --- lam/HISTORY | 1 + .../manual-sources/chapter-configuration.xml | 4 +-- .../manual-sources/chapter-installation.xml | 8 ++++++ lam/lib/cronRunner.inc | 2 +- lam/lib/runCronJobs.inc | 25 ++++++++++++++++++- lam/templates/config/mainmanage.php | 2 +- 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index 7b05bc58c..ddf375897 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -6,6 +6,7 @@ December 2024 9.0 -> Custom scripts: support custom label for module (329) -> Custom scripts: support grouping of manual scripts (329) -> Custom scripts: allow interactive parameters for manual scripts (327) + -> Cron jobs: new script to run all types of cron jobs (runCronJobs.sh), the scripts cron.sh and cronGlobal.sh are deprecated - Fixed bugs: -> Windows: show more than 1000 LDAP entries when paged results is activated in server profile -> WebAuthn: support DNs larger than 64 bytes (358) diff --git a/lam/docs/manual-sources/chapter-configuration.xml b/lam/docs/manual-sources/chapter-configuration.xml index e180830a4..4cdf0a059 100644 --- a/lam/docs/manual-sources/chapter-configuration.xml +++ b/lam/docs/manual-sources/chapter-configuration.xml @@ -1302,9 +1302,9 @@ mysql> GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost'; Dry-run: You can perform a dry-run of the job. This will not perform any actions but only print what would be done. For this please - put "--dryRun" at the end of the command. E.g.: + put "--dry-run" at the end of the command. E.g.: - /usr/share/ldap-account-manager/lib/cron.sh lam 123456789 --dryRun + /usr/share/ldap-account-manager/lib/runCronJobs.sh serverProfile lam --dry-run diff --git a/lam/docs/manual-sources/chapter-installation.xml b/lam/docs/manual-sources/chapter-installation.xml index 14810f3f8..169c2f3c4 100644 --- a/lam/docs/manual-sources/chapter-installation.xml +++ b/lam/docs/manual-sources/chapter-installation.xml @@ -618,6 +618,14 @@ Cron jobs of server profiles no longer use the job token parameter + + + cron.sh and cronGlobal.sh are deprecated and will be removed + in the next release. Use the new command "runCronJobs.sh". E.g. + "runCronJobs.sh all" will run all global jobs and all server + profile jobs. Execute "runCronJobs.sh" to get a list of possible + options. + diff --git a/lam/lib/cronRunner.inc b/lam/lib/cronRunner.inc index 701c5627f..78205b220 100644 --- a/lam/lib/cronRunner.inc +++ b/lam/lib/cronRunner.inc @@ -148,7 +148,7 @@ class CronRunner { // get jobs to run if (empty($cronDatabase->getJobs())) { if ($this->isDryRun) { - echo "No jobs configured for " . $serverProfileName . "\n"; + echo "No jobs configured for " . $serverProfileName . "\n\n"; } return; } diff --git a/lam/lib/runCronJobs.inc b/lam/lib/runCronJobs.inc index c350a55aa..b7f976d11 100644 --- a/lam/lib/runCronJobs.inc +++ b/lam/lib/runCronJobs.inc @@ -25,6 +25,7 @@ namespace LAM\Cron; use LAMConfig; use LAMException; +use ServerProfilePersistenceManager; /** * Global cron job for LAM. @@ -44,7 +45,21 @@ $cronRunner = new CronRunner($isDryRun); $runGlobalActions = isset($argv[2]) && ($argv[2] === 'global'); $runSingleServerProfileActions = isset($argv[2]) && ($argv[2] === 'serverProfile'); -if ($runGlobalActions) { +$runAll = isset($argv[2]) && ($argv[2] === 'all'); +if ($runAll) { + try { + $cronRunner->runGlobalCronJobs(); + $serverProfilePersistenceManager = new ServerProfilePersistenceManager(); + foreach ($serverProfilePersistenceManager->getProfiles() as $serverProfile) { + $cronRunner->runSingleServerProfileActions($serverProfile); + } + } + catch (LAMException $e) { + echo escapeshellcmd($e->getTitle()) . "\n"; + exit(1); + } +} +elseif ($runGlobalActions) { try { $cronRunner->runGlobalCronJobs(); } @@ -67,6 +82,14 @@ else { . "\n" . "Usage:\n" . "\n" + . "Run all cron jobs (global and server profiles):\n" + . "\n" + . " runCronJobs.sh all\n" + . "\n" + . "Run all cron jobs (global and server profiles) in dry-run:\n" + . "\n" + . " runCronJobs.sh all --dry-run\n" + . "\n" . "Run all global cron jobs:\n" . "\n" . " runCronJobs.sh global\n" diff --git a/lam/templates/config/mainmanage.php b/lam/templates/config/mainmanage.php index db76caef5..0160465ba 100644 --- a/lam/templates/config/mainmanage.php +++ b/lam/templates/config/mainmanage.php @@ -732,7 +732,7 @@ // global cron job if ($supportsGlobalCronJob) { $row->add(new htmlSubTitle(_('Global cron job'))); - $cronCommand = dirname(__FILE__, 3) . '/lib/runCronJobs.sh global'; + $cronCommand = dirname(__FILE__, 3) . '/lib/runCronJobs.sh all'; $row->addLabel(new htmlOutputText('Cron command')); $cmdGroup = new htmlGroup(); $cmdGroup->addElement(new htmlOutputText('0 0 * * * ' . $cronCommand)); From dc63b65cc77970ddbe7d10966890e2c1b9b37f76 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 19 Oct 2024 19:23:14 +0200 Subject: [PATCH 4/9] #346 Docker cron --- lam-packaging/debian/changelog | 6 ++++++ lam-packaging/docker/.env | 2 ++ lam-packaging/docker/Dockerfile | 1 + lam-packaging/docker/start.sh | 7 +++++++ lam/VERSION | 2 +- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lam-packaging/debian/changelog b/lam-packaging/debian/changelog index afedc230e..35787a825 100644 --- a/lam-packaging/debian/changelog +++ b/lam-packaging/debian/changelog @@ -1,3 +1,9 @@ +ldap-account-manager (9.0.RC1-1) unstable; urgency=medium + + * new upstream release + + -- Roland Gruber Wed, 19 Oct 2024 19:23:11 +0200 + ldap-account-manager (8.9-1) unstable; urgency=medium * new upstream release diff --git a/lam-packaging/docker/.env b/lam-packaging/docker/.env index 198f4c795..f9e002dd4 100644 --- a/lam-packaging/docker/.env +++ b/lam-packaging/docker/.env @@ -20,6 +20,8 @@ LDAP_USER=cn=admin,dc=my-domain,dc=com LAM_LANG=en_US # LAM configuration master password and password for server profile "lam" LAM_PASSWORD=lam +# run cron jobs (LAM Pro) +LAM_CONFIGURE_CRON=false # configuration database (files or mysql) LAM_CONFIGURATION_DATABASE=files diff --git a/lam-packaging/docker/Dockerfile b/lam-packaging/docker/Dockerfile index 05200c8f3..2efaa00e4 100644 --- a/lam-packaging/docker/Dockerfile +++ b/lam-packaging/docker/Dockerfile @@ -89,6 +89,7 @@ RUN apt-get install --no-install-recommends -y \ php-phpseclib3 \ php-voku-portable-ascii \ libphp-phpmailer \ + cron \ && \ rm /etc/apache2/sites-enabled/*default* && \ rm -rf /var/cache/apt /var/lib/apt/lists/* diff --git a/lam-packaging/docker/start.sh b/lam-packaging/docker/start.sh index 2e94e09f6..d1a9d880b 100755 --- a/lam-packaging/docker/start.sh +++ b/lam-packaging/docker/start.sh @@ -90,6 +90,13 @@ EOF fi +LAM_CONFIGURE_CRON="${LAM_CONFIGURE_CRON:-false}" +if [ "$LAM_CONFIGURE_CRON" = "true" ]; then + echo "Configuring Cron" + echo "0 0 * * * root /usr/share/ldap-account-manager/lib/runCronJobs.sh all" > /etc/cron.d/ldap-account-manager + /usr/sbin/cron +fi + echo "Starting Apache" rm -f /run/apache2/apache2.pid set +u diff --git a/lam/VERSION b/lam/VERSION index fa97ecedc..57a831718 100644 --- a/lam/VERSION +++ b/lam/VERSION @@ -1 +1 @@ -8.9 +9.0.RC1 From d1117945bfde85d3bf08e7700ff6e7d322a5f1b4 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 19 Oct 2024 19:25:07 +0200 Subject: [PATCH 5/9] #346 Docker cron --- lam-packaging/docker/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lam-packaging/docker/start.sh b/lam-packaging/docker/start.sh index d1a9d880b..a93ed4911 100755 --- a/lam-packaging/docker/start.sh +++ b/lam-packaging/docker/start.sh @@ -93,7 +93,7 @@ fi LAM_CONFIGURE_CRON="${LAM_CONFIGURE_CRON:-false}" if [ "$LAM_CONFIGURE_CRON" = "true" ]; then echo "Configuring Cron" - echo "0 0 * * * root /usr/share/ldap-account-manager/lib/runCronJobs.sh all" > /etc/cron.d/ldap-account-manager + echo "0 0 * * * www-data /usr/share/ldap-account-manager/lib/runCronJobs.sh all" > /etc/cron.d/ldap-account-manager /usr/sbin/cron fi From 3e9c3d43b75321c808b77611298057f152ebac69 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 19 Oct 2024 19:52:27 +0200 Subject: [PATCH 6/9] #346 Docker cron --- lam/lib/cronRunner.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lam/lib/cronRunner.inc b/lam/lib/cronRunner.inc index 78205b220..80d513f9c 100644 --- a/lam/lib/cronRunner.inc +++ b/lam/lib/cronRunner.inc @@ -192,6 +192,9 @@ class CronRunner { $ldap->connect($_SESSION['config']->getJobsBindUser(), deobfuscateText($_SESSION['config']->getJobsBindPassword()), true); } catch (LAMException) { + if ($ldap->server() === null) { + throw new LAMException("Unable to connect to LDAP"); + } throw new LAMException("Unable to connect to LDAP with error: " . ldap_error($ldap->server()) . "\n" . getExtendedLDAPErrorMessage($ldap->server())); } $_SESSION['ldap'] = $ldap; From 0320ecd7af28c566e86dbcf17becd3a4a5262854 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 19 Oct 2024 19:54:12 +0200 Subject: [PATCH 7/9] #346 Docker cron --- lam/HISTORY | 1 + 1 file changed, 1 insertion(+) diff --git a/lam/HISTORY b/lam/HISTORY index ddf375897..f141e945b 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -7,6 +7,7 @@ December 2024 9.0 -> Custom scripts: support grouping of manual scripts (329) -> Custom scripts: allow interactive parameters for manual scripts (327) -> Cron jobs: new script to run all types of cron jobs (runCronJobs.sh), the scripts cron.sh and cronGlobal.sh are deprecated + -> Docker: added option to run cron jobs (346) - Fixed bugs: -> Windows: show more than 1000 LDAP entries when paged results is activated in server profile -> WebAuthn: support DNs larger than 64 bytes (358) From 1411a8a52ce48e7118bd174af8e464f94b7f35af Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 19 Oct 2024 20:01:27 +0200 Subject: [PATCH 8/9] #346 Docker cron --- lam/lib/cronRunner.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lam/lib/cronRunner.inc b/lam/lib/cronRunner.inc index 80d513f9c..d96ca4372 100644 --- a/lam/lib/cronRunner.inc +++ b/lam/lib/cronRunner.inc @@ -48,8 +48,6 @@ include_once(__DIR__ . "/config.inc"); include_once(__DIR__ . "/ldap.inc"); /** access to modules */ include_once(__DIR__ . "/modules.inc"); -/** Access to database */ -include_once(__DIR__ . "/database.inc"); /** * Executes cron jobs. @@ -118,6 +116,8 @@ class CronRunner { * @throws LAMException error running actions */ public function runSingleServerProfileActions(string $serverProfileName): void { + /** Access to database */ + include_once(__DIR__ . "/database.inc"); $serverProfilePersistenceManager = new ServerProfilePersistenceManager(); $this->validateServerProfileName($serverProfileName, $serverProfilePersistenceManager); if ($this->isDryRun) { From 9d5cdbbfd2666cf17878d72d17fba812ba05f03a Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 19 Oct 2024 20:05:56 +0200 Subject: [PATCH 9/9] #346 Docker cron --- lam/lib/runCronJobs.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lam/lib/runCronJobs.inc b/lam/lib/runCronJobs.inc index b7f976d11..1adab14d9 100644 --- a/lam/lib/runCronJobs.inc +++ b/lam/lib/runCronJobs.inc @@ -40,7 +40,7 @@ include_once(__DIR__ . "/config.inc"); include_once(__DIR__ . "/cronRunner.inc"); // check parameters -$isDryRun = in_array('--dryRun', $argv) || in_array('--dry-run', $argv); +$isDryRun = isset($argv) && (in_array('--dryRun', $argv) || in_array('--dry-run', $argv)); $cronRunner = new CronRunner($isDryRun); $runGlobalActions = isset($argv[2]) && ($argv[2] === 'global');