Skip to content

Commit 2ffa1e9

Browse files
kevinwangsklguohan
authored andcommitted
[Mellanox] Update hw-management service config (#2325)
Signed-off-by: Kevin Wang <[email protected]>
1 parent b818397 commit 2ffa1e9

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

platform/mellanox/hw-management/Add-systemd-service-config.patch

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,38 @@ index 0000000..d18916d
3636
+[Service]
3737
+Type=oneshot
3838
+EnvironmentFile=/host/machine.conf
39-
+ExecStart=/bin/bash -c "/usr/share/sonic/device/$onie_platform/hw-management start"
40-
+ExecStop=/bin/bash -c "/usr/share/sonic/device/$onie_platform/hw-management stop"
39+
+ExecStart=/bin/bash -c "/usr/bin/hw-management-service.sh $onie_platform start"
40+
+ExecStop=/bin/bash -c "/usr/bin/hw-management-service.sh $onie_platform stop"
4141
+
4242
+[Install]
4343
+WantedBy=multi-user.target
44+
diff --git a/usr/usr/bin/hw-management-service.sh b/usr/usr/bin/hw-management-service.sh
45+
new file mode 100755
46+
index 0000000..e3774e5
47+
--- /dev/null
48+
+++ b/usr/usr/bin/hw-management-service.sh
49+
@@ -0,0 +1,21 @@
50+
+#!/bin/bash
51+
+
52+
+if [ $# -ne 2 ]
53+
+then
54+
+ echo "Error: Invalid parameters"
55+
+ exit 1
56+
+fi
57+
+
58+
+if [ -f /etc/sonic/config_db.json ]
59+
+then
60+
+ mac_exist=$(grep -c "\"mac\"" /etc/sonic/config_db.json)
61+
+ mac_is_none=$(grep "\"mac\"" /etc/sonic/config_db.json | grep -c "\"None\"")
62+
+ if [ "$mac_exist" == "0" ] || [ "$mac_is_none" == "1" ]
63+
+ then
64+
+ echo "No MAC address, need hw-management service in updategraph"
65+
+ exec /usr/share/sonic/device/$1/hw-management $2
66+
+ exit 0
67+
+ fi
68+
+fi
69+
+
70+
+echo "MAC address already exists in config_db.json, do nothing"
4471
diff --git a/debian/rules b/debian/rules
4572
index fc38817..fba4150 100755
4673
--- a/debian/rules

0 commit comments

Comments
 (0)