Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Sep 27, 2024
1 parent a2c83d0 commit 97483c8
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Modules\Email\App\Filament\Resources\DomainsResource\Pages;

use Modules\Email\App\Filament\Resources\EmailDomainResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListDomains extends ListRecords
{
protected static string $resource = EmailDomainResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
78 changes: 78 additions & 0 deletions web/Modules/Email/App/Filament/Resources/EmailDomainResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace Modules\Email\App\Filament\Resources;

use App\Models\Domain;
use Modules\Email\App\Filament\Resources\DomainsResource\Pages;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Modules\Email\App\Models\EmailBox;
use Modules\Email\DkimDomainSetup;

class EmailDomainResource extends Resource
{
protected static ?string $model = Domain::class;

protected static ?string $navigationIcon = 'heroicon-o-inbox-stack';

protected static ?string $navigationGroup = 'Email';

protected static ?int $navigationSort = 0;

public static function form(Form $form): Form
{
return $form
->schema([




]);
}

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('domain')
->searchable()
->sortable(),
])
->filters([
//
])
->actions([
Tables\Actions\Action::make('dkimSetup')
->label('DKIM Setup')
->action(function (Domain $record) {
$output = DkimDomainSetup::run($record->domain);
dd($output);
})
->icon('heroicon-o-pencil'),
])
->bulkActions([
// Tables\Actions\BulkActionGroup::make([
// Tables\Actions\DeleteBulkAction::make(),
// ]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListDomains::route('/'),
];
}
}
34 changes: 34 additions & 0 deletions web/Modules/Email/DkimDomainSetup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Modules\Email;

class DkimDomainSetup
{

public static function run($domain)
{
$dkimPrivateKeyFile = '/etc/opendkim/keys/'.$domain.'/dkim.private';
$dkimTextFile = '/etc/opendkim/keys/'.$domain.'/dkim.txt';

if (is_file($dkimPrivateKeyFile)) {
return [
'privateKey' => file_get_contents($dkimPrivateKeyFile),
'text' => file_get_contents($dkimTextFile),
];
}

shell_exec('sudo mkdir -p /etc/opendkim/keys/'.$domain);
shell_exec('sudo chown -R opendkim:opendkim /etc/opendkim/keys/'.$domain);
shell_exec('sudo chmod go-rw /etc/opendkim/keys/'.$domain);

$output = shell_exec('sudo opendkim-genkey -b 2048 -D /etc/opendkim/keys/'.$domain.' -h rsa-sha256 -r -s dkim -d '.$domain.' -v');

$dkimPrivateKey = file_get_contents($dkimPrivateKeyFile);
$dkimText = file_get_contents($dkimTextFile);

return [
'privateKey' => $dkimPrivateKey,
'text' => $dkimText,
];
}
}
6 changes: 5 additions & 1 deletion web/Modules/Email/shell/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo apt-get update -y
sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved -yq
sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install postfix postfix-mysql -yq
sudo apt-get --no-install-recommends install mailutils -yq
sudo apt-get --no-install-recommends install opendkim opendkim-tools -yq
sudo apt-get --no-install-recommends install opendkim opendkim-tools postfix-policyd-spf-python postfix-pcre -yq
sudo apt-get --no-install-recommends install spamassassin spamc -yq
sudo apt-get --no-install-recommends install clamav clamav-daemon -yq
sudo apt-get --no-install-recommends install amavisd-new -yq
Expand All @@ -14,6 +14,10 @@ ufw allow 587
ufw allow 465
ufw allow 993

mkdir -p /etc/opendkim/keys
chown -R opendkim:opendkim /etc/opendkim
chmod go-rw /etc/opendkim/keys

echo "Done!"


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{-- @if(auth()->id())
<script>
<script>
let hiddenJobQueueNotifications = [];
function hideJobQueueNotification(jobId) {
hiddenJobQueueNotifications.push(jobId);
Expand Down

0 comments on commit 97483c8

Please sign in to comment.