37 lines
929 B
PHP
37 lines
929 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Domain;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class RemoveDkimKey implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public function __construct(
|
|
public int $domainId,
|
|
public string $selector
|
|
) {}
|
|
|
|
public function handle(): void
|
|
{
|
|
$domain = Domain::withTrashed()->findOrFail($this->domainId);
|
|
|
|
$cmd = sprintf(
|
|
'sudo /usr/local/sbin/mailwolt-remove-dkim %s %s',
|
|
escapeshellarg($domain->domain),
|
|
escapeshellarg($this->selector)
|
|
);
|
|
|
|
exec($cmd, $out, $rc);
|
|
if ($rc !== 0) {
|
|
throw new \RuntimeException("mailwolt-remove-dkim failed (rc={$rc})");
|
|
}
|
|
}
|
|
}
|