summaryrefslogtreecommitdiffstats
path: root/index.html
blob: 618f523a0f4c7de976b5b6206208c92247a60575 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Systemd-networkd Control Panel</title>
    <script type="module" src="https://unpkg.com/@fluentui/web-components@2.6.1/dist/web-components.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 2em;
        }

        section {
            margin-bottom: 2em;
        }

        pre {
            background: #f5f5f5;
            padding: 1em;
            border-radius: 6px;
            overflow-x: auto;
        }
    </style>
</head>

<body>

    <h1>Systemd-networkd Control Panel</h1>
    <p>This page shows network status, logs, and allows you to restart network services or reboot the device.
        For more details see <a href="https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html"
            target="_blank">systemd-networkd documentation</a>.</p>

    <section>
        <h2>1. Network Status</h2>
        <p>The command <code>networkctl status --json=short</code> shows current interfaces, addresses, and routes.</p>
        <fluent-button appearance="accent" onclick="loadStatus()">Refresh Status</fluent-button>
        <pre id="status">[Waiting for data]</pre>
    </section>

    <section>
        <h2>2. Network Logs</h2>
        <p>Logs come from <code>journalctl -u systemd-networkd.service</code>. This helps diagnose DHCP and link issues.
        </p>
        <fluent-button onclick="loadLogs()">Show Logs</fluent-button>
        <pre id="logs">[Waiting for logs]</pre>
    </section>

    <section>
        <h2>3. Manage Services</h2>
        <p>
            - Reload networkd after configuration changes.<br>
            - Reboot device if required.
        </p>
        <fluent-button appearance="accent" onclick="reloadNetworkd()">Restart networkd</fluent-button>
        <fluent-button appearance="accent" onclick="rebootDevice()">Reboot device</fluent-button>
    </section>

    <script>
        async function loadStatus() {
            let res = await fetch('/api/status');
            document.getElementById('status').textContent = await res.text();
        }
        async function loadLogs() {
            let res = await fetch('/api/logs');
            document.getElementById('logs').textContent = await res.text();
        }
        async function reloadNetworkd() {
            let res = await fetch('/api/reload', {method: 'POST'});
            alert(await res.text());
        }
        async function rebootDevice() {
            let res = await fetch('/api/reboot', {method: 'POST'});
            alert(await res.text());
        }
    </script>

</body>

</html>