Skip to content

Commit b57a094

Browse files
committed
feat(opnsense): enable PID file monitoring for Defguard Gateway service
Replace nocheck flag with proper PID file configuration to enable OPNsense service status monitoring. The service now correctly tracks the gateway process state via PID file. Changes: - Remove 'nocheck' flag from service definition - Add dynamic PID file path reading from user configuration - Set default PID file location to /var/run/defguard_gateway.pid - Add default value to PidFile model field for consistency - Update form to display default PID file location hint - Simplify config.toml template to always output pidfile with default The PID file location can now be customized by users through the UI, or will default to /var/run/defguard_gateway.pid. This ensures OPNsense can properly monitor and report the gateway service status.
1 parent 5f6187d commit b57a094

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

opnsense/src/etc/inc/plugins.inc.d/defguardgateway.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ function defguardgateway_services()
33
{
44
$services = [];
55

6+
$pidfile = (string) (new OPNsense\DefguardGateway\DefguardGateway())->general->PidFile;
7+
68
$services[] = [
79
"description" => "Defguard Gateway",
810
"configd" => [
911
"start" => ["defguard_gateway start"],
1012
"restart" => ["defguard_gateway restart"],
1113
"stop" => ["defguard_gateway stop"],
1214
],
15+
"pidfile" => empty($pidfile) ? "/var/run/defguard_gateway.pid" : $pidfile,
1316
"name" => "defguard_gateway",
14-
"nocheck" => true,
1517
];
1618

1719
return $services;

opnsense/src/opnsense/mvc/app/controllers/OPNsense/DefguardGateway/forms/general.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<type>text</type>
4343
<hint>Save PID to this file.</hint>
4444
<help>Optional: write PID to this file.</help>
45+
<hint>Default value: /var/run/defguard_gateway.pid</hint>
4546
</field>
4647
<field>
4748
<id>defguardgateway.general.SyslogSocket</id>

opnsense/src/opnsense/mvc/app/models/OPNsense/DefguardGateway/DefguardGateway.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<Required>Y</Required>
3131
</UseSyslog>
3232
<PidFile type="TextField">
33+
<default>/var/run/defguard_gateway.pid</default>
3334
<Required>N</Required>
3435
</PidFile>
3536
<SyslogSocket type="TextField">

opnsense/src/opnsense/service/templates/OPNsense/DefguardGateway/config.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ stats_period = {{ OPNsense.defguardgateway.general.StatsPeriod|default(60) }}
2020
# Required: name of WireGuard interface
2121
ifname = "{{ OPNsense.defguardgateway.general.IfName|default("wg0") }}"
2222
# Optional: write PID to this file
23-
{% if not helpers.empty('OPNsense.defguardgateway.general.PidFile') %}
24-
pidfile = "{{ OPNsense.defguardgateway.general.PidFile }}"
25-
{% endif %}
23+
pidfile = "{{ OPNsense.defguardgateway.general.PidFile|default("/var/run/defguard_gateway.pid") }}"
2624
# Required: enable logging to syslog
2725
{% if OPNsense.defguardgateway.general.UseSyslog == "1" %}
2826
use_syslog = true

0 commit comments

Comments
 (0)