clavarium 0.2.20-next.3 → 0.2.20-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/clavarium-host +13 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/wifi.mjs +3 -2
- package/web/app.js +17 -6
- package/web/index.html +2 -1
- package/web/style.css +4 -0
package/deploy/clavarium-host
CHANGED
|
@@ -124,6 +124,8 @@ NETPLAN_DIR="/etc/netplan"
|
|
|
124
124
|
HAND_FILE="90-clavarium-network.yaml"
|
|
125
125
|
HAND_UNIT="clavarium-network-handover"
|
|
126
126
|
HAND_WAIT="90"
|
|
127
|
+
# Where the kernel lists the network devices (a physical one has a "device" link there).
|
|
128
|
+
SYS_NET="/sys/class/net"
|
|
127
129
|
|
|
128
130
|
refuse() { echo "REFUSED: $*" >&2; exit 78; }
|
|
129
131
|
usage() { echo "usage: clavarium-host [--say-only [--data DIR] [--mnt DIR]] <vm|shelf|folder|work|view|tools|mounts|operator|machines|disks|net|git|server|update|wifi> <verb> [arguments]" >&2; exit 64; }
|
|
@@ -137,7 +139,7 @@ while [ $# -gt 0 ]; do
|
|
|
137
139
|
--test) [ "$(id -u)" != "0" ] || refuse "--test is never for root"; [ "$SAY" = "no" ] || refuse "--test runs for real: not with --say-only"
|
|
138
140
|
TEST="${2:-}"; case "$TEST" in /*) : ;; *) refuse "--test takes an absolute path" ;; esac
|
|
139
141
|
DATA="$TEST"; MNT="$TEST"; WIFI_STATE="$TEST/wifi"; NM_KEYFILES="$TEST/system-connections"; WIFI_WAIT="3"; WIFI_UP_WAIT="3"; WIFI_STEP="0.2"
|
|
140
|
-
HAND_STATE="$TEST/network"; NETPLAN_DIR="$TEST/netplan"; HAND_WAIT="3"; shift 2 ;;
|
|
142
|
+
HAND_STATE="$TEST/network"; NETPLAN_DIR="$TEST/netplan"; HAND_WAIT="3"; SYS_NET="$TEST/sys-net"; shift 2 ;;
|
|
141
143
|
*) break ;;
|
|
142
144
|
esac
|
|
143
145
|
done
|
|
@@ -1209,6 +1211,7 @@ case "$AREA $VERB" in
|
|
|
1209
1211
|
# device <name>
|
|
1210
1212
|
# using <signal 0-100> <ssid> (the SSID is the rest of the line: it may hold spaces)
|
|
1211
1213
|
# saved <ssid> (one per network NetworkManager keeps)
|
|
1214
|
+
# link <cable|wifi> <device> <IPv4 address, or none> (one per physical device)
|
|
1212
1215
|
# last <joining|joined|went-back|back-failed|interrupted> <seconds since 1970>
|
|
1213
1216
|
# lastssid <ssid> lastback <ssid it went back to, or nothing> lastwhy <password|no-connection|no-internet|stopped>
|
|
1214
1217
|
[ $# -eq 0 ] || usage
|
|
@@ -1229,6 +1232,15 @@ case "$AREA $VERB" in
|
|
|
1229
1232
|
done < "$HAND_STATE/last"
|
|
1230
1233
|
fi
|
|
1231
1234
|
hand_busy || ! hand_possible || echo "handover possible"
|
|
1235
|
+
# Its connections: each physical device, a cable or a Wi-Fi, and its address (or none).
|
|
1236
|
+
for d in "$SYS_NET"/*; do
|
|
1237
|
+
n="${d##*/}"
|
|
1238
|
+
[ -e "$d/device" ] && [[ "$n" =~ ^[A-Za-z0-9._-]{1,15}$ ]] || continue
|
|
1239
|
+
kind="cable"; [ ! -d "$d/wireless" ] || kind="wifi"
|
|
1240
|
+
a="$(ip -4 -o addr show dev "$n" scope global 2>/dev/null | sed -n 's/^.* inet \([0-9.]*\)\/[0-9]* .*$/\1/p' | head -1 || true)"
|
|
1241
|
+
[[ "$a" =~ ^[0-9]{1,3}(\.[0-9]{1,3}){3}$ ]] || a="none"
|
|
1242
|
+
printf 'link %s %s %s\n' "$kind" "$n" "$a"
|
|
1243
|
+
done
|
|
1232
1244
|
type -P nmcli >/dev/null 2>&1 || { printf '%s\n' "nmcli no" "wifiwhy no-nmcli"; exit 0; }
|
|
1233
1245
|
echo "nmcli yes"
|
|
1234
1246
|
[ "$(nmcli -t -f RUNNING general 2>/dev/null || true)" = "running" ] || { echo "wifiwhy not-running"; exit 0; }
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.20-next.
|
|
3
|
+
"version": "0.2.20-next.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.20-next.
|
|
9
|
+
"version": "0.2.20-next.4",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/wifi.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* before by itself -- whether or not this server, the page or the request are
|
|
10
10
|
* still there to see it. The outcome is read back from `status()`.
|
|
11
11
|
*
|
|
12
|
-
* status() { available, why, device, using: {ssid, signal} | null, saved: [ssid],
|
|
12
|
+
* status() { available, why, device, using: {ssid, signal} | null, saved: [ssid], links: [{kind: cable|wifi, device, address | null}],
|
|
13
13
|
* last: {state, at, ssid, back, why} | null }
|
|
14
14
|
* why (not available): no-nmcli, not-running, no-device, unmanaged, unreadable
|
|
15
15
|
* last.state: joining, joined, went-back, back-failed, interrupted
|
|
@@ -56,7 +56,7 @@ const WATCH_FOR_MS = 6 * 60_000;
|
|
|
56
56
|
|
|
57
57
|
/* "wifi status", line by line: only the lines of the expected shapes. */
|
|
58
58
|
export function readStatus(text) {
|
|
59
|
-
const out = { available: false, why: null, device: null, using: null, saved: [], last: null, handover: false, hand: null };
|
|
59
|
+
const out = { available: false, why: null, device: null, using: null, saved: [], last: null, handover: false, hand: null, links: [] };
|
|
60
60
|
let nmcli = false;
|
|
61
61
|
for (const line of String(text ?? '').split('\n').slice(0, 300)) {
|
|
62
62
|
const word = line.split(' ', 1)[0]; const rest = line.slice(word.length + 1);
|
|
@@ -67,6 +67,7 @@ export function readStatus(text) {
|
|
|
67
67
|
else if (word === 'saved' && rest) out.saved.push(rest);
|
|
68
68
|
else if (word === 'last') { const m = /^([a-z-]+) (\d{1,12})$/.exec(rest); if (m && STATES.includes(m[1])) out.last = { ...(out.last ?? {}), state: m[1], at: new Date(Number(m[2]) * 1000).toISOString() }; }
|
|
69
69
|
else if (word === 'handover') out.handover = rest === 'possible';
|
|
70
|
+
else if (word === 'link') { const m = /^(cable|wifi) ([A-Za-z0-9._-]{1,15}) (none|\d{1,3}(?:\.\d{1,3}){3})$/.exec(rest); if (m) out.links.push({ kind: m[1], device: m[2], address: m[3] === 'none' ? null : m[3] }); }
|
|
70
71
|
else if (word === 'hand') { const m = /^([a-z-]+) (\d{1,12})$/.exec(rest); if (m && HAND_STATES.includes(m[1])) out.hand = { ...(out.hand ?? {}), state: m[1], at: new Date(Number(m[2]) * 1000).toISOString() }; }
|
|
71
72
|
else if (word === 'handwhy' && /^[a-z-]{1,20}$/.test(rest)) out.hand = { ...(out.hand ?? {}), why: rest };
|
|
72
73
|
else if (['lastssid', 'lastback', 'lastwhy'].includes(word) && line.startsWith(`${word} `)) out.last = { ...(out.last ?? {}), [word.slice(4)]: rest || null };
|
package/web/app.js
CHANGED
|
@@ -4186,11 +4186,11 @@
|
|
|
4186
4186
|
to the network before by itself when the new one does not work within a minute -- this page may
|
|
4187
4187
|
lose the server meanwhile, so it says so before, and reads the outcome when it can again. */
|
|
4188
4188
|
const WIFI_OUTSIDE = {
|
|
4189
|
-
'no-nmcli': 'Wi-Fi is managed outside Clavarium on this server
|
|
4190
|
-
'not-running': 'Wi-Fi is managed outside Clavarium on this server
|
|
4191
|
-
'no-device': 'This server has no Wi-Fi
|
|
4192
|
-
unmanaged: 'Wi-Fi is managed outside Clavarium on this server
|
|
4193
|
-
unreadable: '
|
|
4189
|
+
'no-nmcli': 'Wi-Fi is managed outside Clavarium on this server.',
|
|
4190
|
+
'not-running': 'Wi-Fi is managed outside Clavarium on this server.',
|
|
4191
|
+
'no-device': 'This server has no Wi-Fi.',
|
|
4192
|
+
unmanaged: 'Wi-Fi is managed outside Clavarium on this server.',
|
|
4193
|
+
unreadable: 'The network cannot be read just now.',
|
|
4194
4194
|
};
|
|
4195
4195
|
const WIFI_WHY = { password: 'the password was not accepted', 'no-connection': 'it could not connect', 'no-internet': 'it gave no working network within a minute', stopped: 'the switch was stopped' };
|
|
4196
4196
|
const SECURITY_WORDS = { open: 'open', wpa: 'password', wpa3: 'password (WPA3)', wep: 'old protection (WEP): not joined here', enterprise: 'user and certificate (802.1X): not joined here', other: 'not joined here' };
|
|
@@ -4248,8 +4248,19 @@
|
|
|
4248
4248
|
}
|
|
4249
4249
|
wifiNow = s;
|
|
4250
4250
|
paintHand(s);
|
|
4251
|
+
/* Its connections, cable and Wi-Fi, each with its address. */
|
|
4252
|
+
const links = $('net-links'); links.replaceChildren();
|
|
4253
|
+
for (const l of s.links ?? []) {
|
|
4254
|
+
const li = el('li', l.address ? '' : 'hint');
|
|
4255
|
+
li.append(el('b', '', l.kind === 'wifi' ? 'Wi-Fi' : 'Cable'), ` (${l.device}): `, l.address ? el('code', '', l.address) : 'not connected');
|
|
4256
|
+
links.append(li);
|
|
4257
|
+
}
|
|
4258
|
+
links.hidden = !(s.links ?? []).length;
|
|
4251
4259
|
$('wifi-controls').hidden = !s.available;
|
|
4252
|
-
|
|
4260
|
+
/* While it is handed over, its progress alone is said. */
|
|
4261
|
+
const handing = ['installing', 'switching'].includes(s.hand?.state);
|
|
4262
|
+
if (!s.available) { $('wifi-now').textContent = handing ? '' : s.handover ? 'Clavarium does not manage this server\'s network yet.' : WIFI_OUTSIDE[s.why] ?? WIFI_OUTSIDE.unreadable; $('wifi-now').hidden = handing; $('wifi-last').hidden = true; return; }
|
|
4263
|
+
$('wifi-now').hidden = false;
|
|
4253
4264
|
$('wifi-now').replaceChildren();
|
|
4254
4265
|
if (s.using) $('wifi-now').append(el('span', '', 'On '), el('b', '', s.using.ssid), el('span', '', ` (Wi-Fi, ${s.device}) `), signalBars(s.using.signal));
|
|
4255
4266
|
else $('wifi-now').textContent = `Not on a Wi-Fi network (${s.device}).`;
|
package/web/index.html
CHANGED
|
@@ -712,10 +712,11 @@
|
|
|
712
712
|
<!-- NETWORK: this server's Wi-Fi (server/wifi.mjs; done as root by the host program,
|
|
713
713
|
through NetworkManager). A switch goes back by itself when the new network does not work. -->
|
|
714
714
|
<details class="chapter" id="settings-wifi-top" data-chapter="s-network">
|
|
715
|
-
<summary><span class="chapter-title">Network</span><span class="chapter-about">
|
|
715
|
+
<summary><span class="chapter-title">Network</span><span class="chapter-about">Its cable and its Wi-Fi.</span></summary>
|
|
716
716
|
<div class="chapter-body">
|
|
717
717
|
<div id="wifi" tabindex="-1">
|
|
718
718
|
<p id="wifi-now" role="status"></p>
|
|
719
|
+
<ul id="net-links" class="net-links" hidden></ul>
|
|
719
720
|
<p id="wifi-last" class="hint" role="status" hidden></p>
|
|
720
721
|
<!-- ITS NETWORK SET UP OUTSIDE CLAVARIUM (netplan and systemd-networkd, as the Ubuntu installer leaves it): handed over to NetworkManager, back as it was if it does not work. -->
|
|
721
722
|
<div id="wifi-hand" hidden>
|
package/web/style.css
CHANGED
|
@@ -1425,3 +1425,7 @@ button.inline.more-recent { text-decoration: none; }
|
|
|
1425
1425
|
.ts-way { grid-column: 2 / -1; }
|
|
1426
1426
|
.ts-size { grid-column: 2; } .ts-state { grid-column: 3; text-align: right; }
|
|
1427
1427
|
}
|
|
1428
|
+
|
|
1429
|
+
/* Network: its connections, one a line. */
|
|
1430
|
+
.net-links { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
1431
|
+
.net-links code { font-size: .875rem; }
|