✨ feat(command): Ajoute la commande de synchronisation pour les données.
🔨 refactor(ansible): Ajoute une tâche cron pour la synchronisation des données.
This commit is contained in:
@@ -203,6 +203,15 @@
|
||||
job: "php {{ site_path }}/bin/console mainframe:cron:customer"
|
||||
user: root
|
||||
|
||||
- name: "Cron Task sync"
|
||||
ansible.builtin.cron:
|
||||
name: "Mainframe - Sync"
|
||||
minute: "0"
|
||||
hour: "*"
|
||||
user: "root"
|
||||
job: "php {{ site_path }}/bin/console mainframe:cron:sync"
|
||||
state: present
|
||||
|
||||
# Ensure final state of /public/media, if you want 'bot' to own it for uploads
|
||||
- name: Final check for public/media ownership and permissions
|
||||
ansible.builtin.file:
|
||||
|
||||
50
src/Command/SyncCommand.php
Normal file
50
src/Command/SyncCommand.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Entity\Account;
|
||||
use App\Entity\CustomerDns;
|
||||
use App\Service\Generator\TempPasswordGenerator;
|
||||
use App\Service\Mailer\Event\CreatedAdminEvent;
|
||||
use App\Service\Ovh\Client;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
#[AsCommand(name: 'mainframe:cron:sync')]
|
||||
class SyncCommand extends Command
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager,private readonly Client $ovhClient,?string $name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->title("Sync Data");
|
||||
//sync dns
|
||||
foreach ($this->entityManager->getRepository(CustomerDns::class)->findAll() as $customerDns) {
|
||||
$io->info('Sync DNS - '.$customerDns->getDns());
|
||||
if($customerDns->getRegistar() == "ovh") {
|
||||
$data = $this->ovhClient->info($customerDns->getNdd());
|
||||
if(!is_null($data)){
|
||||
$d = \DateTime::createFromFormat(\DateTime::ATOM,$data['expired']);
|
||||
$customerDns->setExpiredAt($d);
|
||||
$this->entityManager->persist($customerDns);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user