summaryrefslogtreecommitdiff
path: root/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh')
-rw-r--r--meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh
new file mode 100644
index 000000000..65fc0bc50
--- /dev/null
+++ b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+BOOT_SERVICE_NAME="xyz.openbmc_project.State.Host"
+BOOT_STATUS_OBJPATH="/xyz/openbmc_project/state/os"
+BOOT_INTERFACE_NAME="xyz.openbmc_project.State.OperatingSystem.Status"
+BOOT_Property="OperatingSystemState"
+
+LED_SERVICE_NAME="xyz.openbmc_project.LED.GroupManager"
+LED_INACTIVE_OBJPATH="/xyz/openbmc_project/led/groups/boot_status_inactive"
+LED_STANDBY_OBJPATH="/xyz/openbmc_project/led/groups/boot_status_standby"
+LED_INTERFACE_NAME="xyz.openbmc_project.Led.Group"
+LED_Property="Asserted"
+
+dbus_state=0
+boot_status=""
+check_flag=0
+
+mapper wait $LED_INACTIVE_OBJPATH
+mapper wait $LED_STANDBY_OBJPATH
+while true; do
+ boot_status=$(busctl get-property $BOOT_SERVICE_NAME $BOOT_STATUS_OBJPATH $BOOT_INTERFACE_NAME $BOOT_Property | awk '{print $2}')
+
+ if [ $boot_status != "\"Standby\"" ] && [ $check_flag -eq 0 ];then
+ busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b true
+ check_flag=1
+ elif [ $boot_status == "\"Standby\"" ];then
+ busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b false
+ busctl set-property $LED_SERVICE_NAME $LED_STANDBY_OBJPATH $LED_INTERFACE_NAME $LED_Property b true
+ break
+ fi
+ sleep 1
+done
+
+exit 0