mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-22 13:57:50 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4317efff68 |
@@ -22,16 +22,15 @@ else if (_status != null)
|
|||||||
{
|
{
|
||||||
<section class="page-section">
|
<section class="page-section">
|
||||||
<h2 class="page-section-title">Service configuration</h2>
|
<h2 class="page-section-title">Service configuration</h2>
|
||||||
<ul class="list-unstyled small mb-0">
|
<p class="mb-1"><strong>Config files (load order):</strong></p>
|
||||||
<li><strong>Main config:</strong> @(_status.MainConfigPath ?? "—") @(_status.MainConfigPathExists ? "✓" : "(missing)")</li>
|
<ul class="list-unstyled small ms-2 mb-0">
|
||||||
<li><strong>Managed file:</strong> @(_status.ManagedFilePath ?? "—") @(_status.ManagedFilePathExists ? "✓" : "(not created yet)")</li>
|
@if (_configSet != null && _configSet.Files?.Count > 0)
|
||||||
</ul>
|
{
|
||||||
@if (_configSet != null && _configSet.Files?.Count > 0)
|
|
||||||
{
|
|
||||||
<p class="mb-1 mt-2"><strong>Config set (load order):</strong></p>
|
|
||||||
<ul class="list-unstyled small ms-2 mb-0">
|
|
||||||
@foreach (var f in _configSet.Files)
|
@foreach (var f in _configSet.Files)
|
||||||
{
|
{
|
||||||
|
var isMain = string.Equals(f.Path, _status.MainConfigPath, StringComparison.Ordinal);
|
||||||
|
var isManaged = f.IsManaged;
|
||||||
|
var exists = isMain ? _status.MainConfigPathExists : (isManaged ? _status.ManagedFilePathExists : (bool?)null);
|
||||||
<li>
|
<li>
|
||||||
@if (f.IsManaged)
|
@if (f.IsManaged)
|
||||||
{
|
{
|
||||||
@@ -41,12 +40,18 @@ else if (_status != null)
|
|||||||
{
|
{
|
||||||
<span class="badge bg-secondary me-1">@(f.Source.ToString().ToLowerInvariant())</span>
|
<span class="badge bg-secondary me-1">@(f.Source.ToString().ToLowerInvariant())</span>
|
||||||
}
|
}
|
||||||
@f.FileName
|
@f.Path
|
||||||
<span class="text-muted">(@f.Path)</span>
|
@if (exists == true) { <text> ✓</text> }
|
||||||
|
@if (exists == false) { <text> @(isManaged ? "(not created yet)" : "(missing)")</text> }
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
</ul>
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
<li><strong>Main config:</strong> @(_status.MainConfigPath ?? "—") @(_status.MainConfigPathExists ? "✓" : "(missing)")</li>
|
||||||
|
<li><strong>Managed file:</strong> @(_status.ManagedFilePath ?? "—") @(_status.ManagedFilePathExists ? "✓" : "(not created yet)")</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
<EffectiveConfigSection Status="_status" />
|
<EffectiveConfigSection Status="_status" />
|
||||||
@if (_status.ReloadCommandConfigured)
|
@if (_status.ReloadCommandConfigured)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ public class EnsureManagedConfigHostedService : IApplicationHostedService
|
|||||||
var mainDir = Path.GetDirectoryName(mainFull) ?? "";
|
var mainDir = Path.GetDirectoryName(mainFull) ?? "";
|
||||||
var managedPath = Path.GetFullPath(set.ManagedFilePath);
|
var managedPath = Path.GetFullPath(set.ManagedFilePath);
|
||||||
var managedDir = Path.GetDirectoryName(managedPath) ?? "";
|
var managedDir = Path.GetDirectoryName(managedPath) ?? "";
|
||||||
var confFileLine = "conf-file=" + Path.GetRelativePath(mainDir, managedPath);
|
// Use absolute path so dnsmasq finds the file regardless of CWD (e.g. systemd may run with CWD=/).
|
||||||
|
var confFileLine = "conf-file=" + managedPath;
|
||||||
|
|
||||||
var lines = File.Exists(mainFull)
|
var lines = File.Exists(mainFull)
|
||||||
? (await File.ReadAllLinesAsync(mainFull, DnsmasqFileEncoding.Utf8NoBom, cancellationToken)).ToList()
|
? (await File.ReadAllLinesAsync(mainFull, DnsmasqFileEncoding.Utf8NoBom, cancellationToken)).ToList()
|
||||||
@@ -62,6 +63,7 @@ public class EnsureManagedConfigHostedService : IApplicationHostedService
|
|||||||
var value = trimmed.Length > 10 ? trimmed[10..].Trim() : "";
|
var value = trimmed.Length > 10 ? trimmed[10..].Trim() : "";
|
||||||
if (string.IsNullOrEmpty(value))
|
if (string.IsNullOrEmpty(value))
|
||||||
continue;
|
continue;
|
||||||
|
// Resolve relative to main config dir; absolute value is used as-is.
|
||||||
var resolved = Path.GetFullPath(Path.Combine(mainDir, value));
|
var resolved = Path.GetFullPath(Path.Combine(mainDir, value));
|
||||||
if (string.Equals(resolved, managedPath, StringComparison.Ordinal))
|
if (string.Equals(resolved, managedPath, StringComparison.Ordinal))
|
||||||
lines.RemoveAt(i);
|
lines.RemoveAt(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user