From b4042547442db850c25e11be32f2eaa4412cbc55 Mon Sep 17 00:00:00 2001 From: Vunny Sodhi Date: Mon, 29 Jul 2024 14:29:35 +0300 Subject: [PATCH] logging: Update the mac address retrieval With this patch will be calling hwinfo utility to retrieve Permanent HW Address / MAC Address for wlp0s5f0 network interface. As we cannot rely on the sys interface for mac retrieval possibly due to MAC randomization. Signed-off-by: Vunny Sodhi --- modules/common/logging/hw-mac-retrieve.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/common/logging/hw-mac-retrieve.nix b/modules/common/logging/hw-mac-retrieve.nix index 081a69f52..f011f9a67 100644 --- a/modules/common/logging/hw-mac-retrieve.nix +++ b/modules/common/logging/hw-mac-retrieve.nix @@ -8,7 +8,7 @@ }: let # TODO: replace sshCommand and MacCommand with givc rpc to retrieve Mac Address sshCommand = "${pkgs.sshpass}/bin/sshpass -p ghaf ${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no ghaf@net-vm"; - macCommand = "cat /sys/class/net/wlp0s5f0/address"; + macCommand = "${pkgs.hwinfo}/bin/hwinfo --network --only /class/net/wlp0s5f0 | ${pkgs.gawk}/bin/awk '/Permanent HW Address/ {print $4}'"; macAddressPath = config.ghaf.logging.identifierFilePath; in { options.ghaf.logging.identifierFilePath = lib.mkOption { @@ -36,6 +36,8 @@ in { ExecStart = '' ${pkgs.bash}/bin/bash -c "echo -n $(${sshCommand} ${macCommand}) > ${macAddressPath}" ''; + Restart = "on-failure"; + RestartSec = "1"; }; }; };