Skip to content

Commit

Permalink
[Mellanox] Update hw-management service config (#2325)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Wang <[email protected]>
  • Loading branch information
kevinwangsk authored and lguohan committed Dec 1, 2018
1 parent b818397 commit 2ffa1e9
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions platform/mellanox/hw-management/Add-systemd-service-config.patch
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,38 @@ index 0000000..d18916d
+[Service]
+Type=oneshot
+EnvironmentFile=/host/machine.conf
+ExecStart=/bin/bash -c "/usr/share/sonic/device/$onie_platform/hw-management start"
+ExecStop=/bin/bash -c "/usr/share/sonic/device/$onie_platform/hw-management stop"
+ExecStart=/bin/bash -c "/usr/bin/hw-management-service.sh $onie_platform start"
+ExecStop=/bin/bash -c "/usr/bin/hw-management-service.sh $onie_platform stop"
+
+[Install]
+WantedBy=multi-user.target
diff --git a/usr/usr/bin/hw-management-service.sh b/usr/usr/bin/hw-management-service.sh
new file mode 100755
index 0000000..e3774e5
--- /dev/null
+++ b/usr/usr/bin/hw-management-service.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]
+then
+ echo "Error: Invalid parameters"
+ exit 1
+fi
+
+if [ -f /etc/sonic/config_db.json ]
+then
+ mac_exist=$(grep -c "\"mac\"" /etc/sonic/config_db.json)
+ mac_is_none=$(grep "\"mac\"" /etc/sonic/config_db.json | grep -c "\"None\"")
+ if [ "$mac_exist" == "0" ] || [ "$mac_is_none" == "1" ]
+ then
+ echo "No MAC address, need hw-management service in updategraph"
+ exec /usr/share/sonic/device/$1/hw-management $2
+ exit 0
+ fi
+fi
+
+echo "MAC address already exists in config_db.json, do nothing"
diff --git a/debian/rules b/debian/rules
index fc38817..fba4150 100755
--- a/debian/rules
Expand Down

0 comments on commit 2ffa1e9

Please sign in to comment.