feat(server): implement server patch check notifications

- Added a new job, ServerPatchCheckJob, to handle server patch checks and notifications.
- Introduced a new notification class, ServerPatchCheck, for sending updates via email, Discord, Slack, Pushover, and Telegram.
- Updated notification settings models to include server patch notification options for email, Discord, Slack, Pushover, and Telegram.
- Created a migration to add server patch notification fields to the respective settings tables.
- Enhanced the UI to allow users to enable/disable server patch notifications across different channels.
This commit is contained in:
Andras Bacsai
2025-05-26 14:03:59 +02:00
parent 86f6cd5fd6
commit 6ea6d2742b
23 changed files with 520 additions and 21 deletions

View File

@@ -0,0 +1,53 @@
<x-emails.layout>
{{ $total_updates }} package updates are available for your server {{ $name }}.
## Summary
- Operating System: {{ ucfirst($osId) }}
- Package Manager: {{ $package_manager }}
- Total Updates: {{ $total_updates }}
## Available Updates
@if ($total_updates > 0)
@foreach ($updates as $update)
Package: {{ $update['package'] }} ({{ $update['architecture'] }}), from version {{ $update['current_version'] }} to {{ $update['new_version'] }} at repository {{ $update['repository'] ?? 'Unknown' }}
@endforeach
## Security Considerations
Some of these updates may include important security patches. We recommend reviewing and applying these updates promptly.
### Critical packages that may require container/server/service restarts:
@php
$criticalPackages = collect($updates)->filter(function ($update) {
return str_contains(strtolower($update['package']), 'docker') ||
str_contains(strtolower($update['package']), 'kernel') ||
str_contains(strtolower($update['package']), 'openssh') ||
str_contains(strtolower($update['package']), 'ssl');
});
@endphp
@if ($criticalPackages->count() > 0)
@foreach ($criticalPackages as $package)
- {{ $package['package'] }}: {{ $package['current_version'] }} {{ $package['new_version'] }}
@endforeach
@else
No critical packages requiring container restarts detected.
@endif
## Next Steps
1. Review the available updates
2. Plan maintenance window if critical packages are involved
3. Apply updates through the Coolify dashboard
4. Monitor services after updates are applied
@else
Your server is up to date! No packages require updating at this time.
@endif
---
You can manage server patches in your [Coolify Dashboard]({{ $server_url }}).
</x-emails.layout>

View File

@@ -78,6 +78,8 @@
label="Server Reachable" />
<x-forms.checkbox instantSave="saveModel" id="serverUnreachableDiscordNotifications"
label="Server Unreachable" />
<x-forms.checkbox instantSave="saveModel" id="serverPatchDiscordNotifications"
label="Server Patching" />
</div>
</div>
</div>

View File

@@ -155,6 +155,8 @@
label="Server Reachable" />
<x-forms.checkbox instantSave="saveModel" id="serverUnreachableEmailNotifications"
label="Server Unreachable" />
<x-forms.checkbox instantSave="saveModel" id="serverPatchEmailNotifications"
label="Server Patching" />
</div>
</div>
</div>

View File

@@ -80,6 +80,8 @@
label="Server Reachable" />
<x-forms.checkbox instantSave="saveModel" id="serverUnreachablePushoverNotifications"
label="Server Unreachable" />
<x-forms.checkbox instantSave="saveModel" id="serverPatchPushoverNotifications"
label="Server Patching" />
</div>
</div>
</div>

View File

@@ -24,8 +24,8 @@
<x-forms.checkbox instantSave="instantSaveSlackEnabled" id="slackEnabled" label="Enabled" />
</div>
<x-forms.input type="password"
helper="Create a Slack APP and generate a Incoming Webhook URL. <br><a class='inline-block underline dark:text-white' href='https://api.slack.com/apps' target='_blank'>Create Slack APP</a>" required
id="slackWebhookUrl" label="Webhook" />
helper="Create a Slack APP and generate a Incoming Webhook URL. <br><a class='inline-block underline dark:text-white' href='https://api.slack.com/apps' target='_blank'>Create Slack APP</a>"
required id="slackWebhookUrl" label="Webhook" />
</form>
<h2 class="mt-4">Notification Settings</h2>
<p class="mb-4">
@@ -73,6 +73,7 @@
label="Server Reachable" />
<x-forms.checkbox instantSave="saveModel" id="serverUnreachableSlackNotifications"
label="Server Unreachable" />
<x-forms.checkbox instantSave="saveModel" id="serverPatchSlackNotifications" label="Server Patching" />
</div>
</div>
</div>

View File

@@ -27,8 +27,9 @@
<x-forms.input type="password" autocomplete="new-password"
helper="Get it from the <a class='inline-block underline dark:text-white' href='https://t.me/botfather' target='_blank'>BotFather Bot</a> on Telegram."
required id="telegramToken" label="Bot API Token" />
<x-forms.input type="password" autocomplete="new-password" helper="Add your bot to a group chat and add its Chat ID here." required
id="telegramChatId" label="Chat ID" />
<x-forms.input type="password" autocomplete="new-password"
helper="Add your bot to a group chat and add its Chat ID here." required id="telegramChatId"
label="Chat ID" />
</div>
</form>
<h2 class="mt-4">Notification Settings</h2>
@@ -151,7 +152,6 @@
id="telegramNotificationsServerReachableThreadId" />
</div>
<div class="pl-1 flex gap-2">
<div class="w-96">
<x-forms.checkbox instantSave="saveModel" id="serverUnreachableTelegramNotifications"
@@ -160,6 +160,15 @@
<x-forms.input type="password" placeholder="Custom Telegram Thread ID"
id="telegramNotificationsServerUnreachableThreadId" />
</div>
<div class="pl-1 flex gap-2">
<div class="w-96">
<x-forms.checkbox instantSave="saveModel" id="serverPatchTelegramNotifications"
label="Server Patching" />
</div>
<x-forms.input type="password" placeholder="Custom Telegram Thread ID"
id="telegramNotificationsServerPatchThreadId" />
</div>
</div>
</div>
</div>

View File

@@ -23,7 +23,7 @@
<x-forms.button type="button" wire:click="$dispatch('checkForUpdatesDispatch')">
Check Now</x-forms.button>
</div>
<div>Update your servers automatically.</div>
<div>Update your servers semi-automatically.</div>
<div>
<div class="flex flex-col gap-6 pt-4">
<div class="flex flex-col">
@@ -38,18 +38,20 @@
<div class="text-green-500">Your server is up to date.</div>
@endif
@if (isset($updates) && count($updates) > 0)
<x-modal-confirmation title="Confirm package update?"
buttonTitle="Update All
<div class="pb-2">
<x-modal-confirmation title="Confirm package update?"
buttonTitle="Update All
Packages"
isHighlightedButton submitAction="updateAllPackages" dispatchAction
:actions="[
'All packages will be updated to the latest version.',
'This action could restart your currently running containers if docker will be updated.',
]" confirmationText="Update All Packages"
confirmationLabel="Please confirm the execution of the actions by entering the name below"
shortConfirmationLabel="Name" :confirmWithPassword=false
step2ButtonText="Update All
isHighlightedButton submitAction="updateAllPackages" dispatchAction
:actions="[
'All packages will be updated to the latest version.',
'This action could restart your currently running containers if docker will be updated.',
]" confirmationText="Update All Packages"
confirmationLabel="Please confirm the execution of the actions by entering the name below"
shortConfirmationLabel="Name" :confirmWithPassword=false
step2ButtonText="Update All
Packages" />
</div>
<table>
<thead>
<tr>
@@ -65,7 +67,7 @@
@foreach ($updates as $update)
<tr>
<td class="inline-flex gap-2 justify-center items-center">
@if (data_get_str($update, 'package')->contains('docker'))
@if (data_get_str($update, 'package')->contains('docker') || data_get_str($update, 'package')->contains('kernel'))
<x-helper :helper="'This package will restart your currently running containers'">
<x-slot:icon>
<svg class="w-4 h-4 text-red-500 block"