summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/canonical_bond.py
diff options
context:
space:
mode:
authorsommerfeld <sommerfeld@sommerfeld.dev>2026-09-22 14:14:52 +0100
committersommerfeld <sommerfeld@sommerfeld.dev>2026-09-22 14:14:52 +0100
commit05bf213010f4a09487c1bb67e73e61bd31bb33b7 (patch)
treee6d42ca099dec3186db25954568149a8f7e368be /scripts/canonical_bond.py
parent5682899d6bf944f6f09e1c055b61052335d2c3e0 (diff)
downloaddotfiles-05bf213010f4a09487c1bb67e73e61bd31bb33b7.tar.gz
dotfiles-05bf213010f4a09487c1bb67e73e61bd31bb33b7.tar.bz2
dotfiles-05bf213010f4a09487c1bb67e73e61bd31bb33b7.zip
Find bond source profiles through NetworkManager
Diffstat (limited to 'scripts/canonical_bond.py')
-rw-r--r--scripts/canonical_bond.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/canonical_bond.py b/scripts/canonical_bond.py
index d7783c8..a097436 100644
--- a/scripts/canonical_bond.py
+++ b/scripts/canonical_bond.py
@@ -102,12 +102,13 @@ def port_profile(source, kind, identity, priority):
def profile_source(identity):
- for directory in ("/etc", "/run", "/usr/lib"):
- for path in Path(directory, "NetworkManager/system-connections").glob("*"):
- if path.is_file():
- text = path.read_text()
- if keyfile(text).get("connection", "uuid", fallback="") == identity:
- return text
+ profiles = nmcli("--escape", "no", "-g", "UUID,FILENAME", "connection", "show")
+ for row in profiles.splitlines():
+ uuid_value, _, filename = row.partition(":")
+ if uuid_value == identity and filename:
+ path = Path(filename)
+ if path.is_absolute() and path.is_file():
+ return path.read_text()
raise ValueError(f"No saved NetworkManager keyfile for {identity}")