Add script to generate entries for external ports

For the user to be able to enable them in runtime
This commit is contained in:
Mattias Walström
2024-02-23 14:01:23 +01:00
parent 6f41ea5ccb
commit 6099ac79e2
3 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
pkglibexec_SCRIPTS = bootstrap error load \
gen-hostkeys gen-admin-auth gen-hostname gen-interfaces gen-motd
gen-hostkeys gen-admin-auth gen-hostname gen-interfaces gen-motd gen-hardware
+1
View File
@@ -98,6 +98,7 @@ factory()
# Create an overlay for /etc/hostname to change the default in an br2-external
gen-hostname >"$FACTORY_D/20-hostname.json"
gen-motd >"$FACTORY_D/20-motd.json"
gen-hardware >"$FACTORY_D/20-hardware.json"
# shellcheck disable=SC2086
gen-interfaces $GEN_IFACE_OPTS >"$FACTORY_D/20-interfaces.json"
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
set -e
usb_ports=$(cat /run/system.json | jq -r '.["usb-ports"] | map(.name) | unique | join(" ")')
gen_port()
{
local port="$1"
cat <<EOF
{
"class": "infix-hardware:usb",
"name": "$port",
"state": {
"admin-state": "unlocked"
}
}
EOF
}
cat <<EOF
{
"ietf-hardware:hardware": {
"component": [
$(for port in $usb_ports; do gen_port "$port"; done)
]}
}
EOF