Cron.php no longer getting overwritten after update

Configuration needed to support this, please review documentation.
This commit is contained in:
Pinga 2025-01-23 12:56:59 +02:00
parent d6233357fa
commit a63f733a7c
2 changed files with 58 additions and 4 deletions

View file

@ -1,14 +1,47 @@
<?php
// Configuration
$cronJobConfig = [
// ========================== Instructions ==========================
// To customize the cron job settings without modifying this script,
// create a file at the following path:
//
// /opt/registry/automation/cron_config.php
//
// The file should return an array with your configuration values.
// Example content for cron_config.php:
//
// <?php
// return [
// 'accounting' => false, // Enable or disable accounting
// 'backup' => false, // Enable or disable backup
// 'backup_upload' => false, // Enable or disable backup upload
// 'gtld_mode' => false, // Enable or disable gTLD mode
// 'spec11' => false, // Enable or disable Spec 11 checks
// 'dnssec' => false, // Enable or disable DNSSEC
// ];
//
// Any keys omitted in cron_config.php will fall back to the defaults
// defined in this script.
// ==================================================================
// Default Configuration
$defaultConfig = [
'accounting' => false, // Set to true to enable
'backup' => false, // Set to true to enable
'backup_upload' => false, // Set to true to enable
'gtld_mode' => false, // Set to true to enable
'spec11' => false, // Set to true to enable
'dnssec' => false, // Set to true to enable
];
// Load External Config if Exists
$configFilePath = '/opt/registry/automation/cron_config.php';
if (file_exists($configFilePath)) {
$externalConfig = require $configFilePath;
$cronJobConfig = array_merge($defaultConfig, $externalConfig);
} else {
$cronJobConfig = $defaultConfig;
}
require __DIR__ . '/vendor/autoload.php';
use GO\Scheduler;
@ -24,12 +57,16 @@ $scheduler->php('/opt/registry/automation/domain-lifecycle-manager.php')->at('*/
$scheduler->php('/opt/registry/automation/auto-approve-transfer.php')->at('*/30 * * * *');
$scheduler->php('/opt/registry/automation/auto-clean-unused-contact-and-host.php')->at('5 0 * * *');
// Conditional Cron Jobs
if ($cronJobConfig['accounting']) {
$scheduler->php('/opt/registry/automation/send-invoice.php')->at('1 0 1 * *');
}
if ($cronJobConfig['backup']) {
$scheduler->raw('/opt/registry/automation/vendor/bin/phpbu --configuration=/opt/registry/automation/backup.json')->at('15 * * * *');
}
if ($cronJobConfig['backup_upload']) {
$scheduler->php('/opt/registry/automation/backup-upload.php')->at('30 * * * *');
}
@ -50,4 +87,5 @@ if ($cronJobConfig['gtld_mode']) {
$scheduler->php('/opt/registry/automation/reporting.php')->at('1 0 1 * *');
}
// Run Scheduled Tasks
$scheduler->run();

View file

@ -137,7 +137,7 @@ To set up backups in Namingo:
1. Rename `/opt/registry/automation/backup.json.dist` and `/opt/registry/automation/backup-upload.json.dist` to `backup.json` and `backup-upload.json`, respectively. Edit both files to include the correct database and other required details.
2. Enable the backup functionality in `cron.php` and ensure cronjobs are configured and active on your server. Check the server's cronjob list to verify.
2. Enable the backup functionality in `cron.php` or `cron_config.php` and make sure you follow the instructions in section **1.4.7. Running the Automation System** to activate the automation system on your server.
#### 1.4.6. RDE (Registry data escrow) configuration
@ -190,7 +190,23 @@ gpg2 --armor --export-secret-keys your.email@example.com > privatekey.asc
#### 1.4.7. Running the Automation System
Once you have successfully configured all automation scripts, you are ready to initiate the automation system. Please review ```/opt/registry/automation/cron.php``` and enable all services if you are running a gTLD. Then proceed by adding the following cron job to the system crontab using ```crontab -e```:
1. After successfully configuring all the components of the automation system as outlined in the previous sections, you can proceed to initiate the system.
2. Create the configuration file at `/opt/registry/automation/cron_config.php` with the specified structure, and adjust the values to suit your requirements. Note: If you are managing a gTLD, all services must be enabled for proper operation.
```php
<?php
return [
'accounting' => false, // Enable or disable accounting
'backup' => false, // Enable or disable backup
'backup_upload' => false, // Enable or disable backup upload
'gtld_mode' => false, // Enable or disable gTLD mode
'spec11' => false, // Enable or disable Spec 11 checks
'dnssec' => false, // Enable or disable DNSSEC
];
```
3. Add the following cron job to the system crontab using ```crontab -e```:
```bash
* * * * * /usr/bin/php /opt/registry/automation/cron.php 1>> /dev/null 2>&1