meta-quanta: gbs: boot status led action

The sys_boot_status LED would be set blinking
until host post done. When host post done, the
action of sys_boot_status would be set on

Note:
1. LED action is set in led.yaml under
   "gbs-led-manager-config" directory
2. sys_boot_status LED gpio is set in kernel dts

(From meta-quanta rev: 961e0f5890d3bc7b25491a024a694ea9ed01cb70)

Signed-off-by: George Hung <george.hung@quantatw.com>
Change-Id: Ia2f5ff923b8dc6a7eda31d8d37e63a31d6d62028
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.service b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.service
new file mode 100644
index 0000000..0627a94
--- /dev/null
+++ b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Boot Status LED Manager
+After=xyz.openbmc_project.LED.GroupManager.service
+Requires=xyz.openbmc_project.LED.GroupManager.service
+
+[Service]
+ExecStart=/usr/bin/boot-status-led.sh
+StandardOutput=syslog
+Type=simple
+RemainAfterExit=yes
+Restart=no
+
+[Install]
+WantedBy=multi-user.target
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 0000000..65fc0bc
--- /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
diff --git a/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/gbs-boot-status-led.bb b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/gbs-boot-status-led.bb
new file mode 100644
index 0000000..61c6ed4
--- /dev/null
+++ b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/gbs-boot-status-led.bb
@@ -0,0 +1,25 @@
+SUMMARY = "OpenBMC Quanta Boot Status LED Service"
+DESCRIPTION = "OpenBMC Quanta Boot Status LED Daemon."
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit systemd
+
+DEPENDS += "systemd"
+RDEPENDS_${PN} += "bash"
+
+SRC_URI = " file://boot-status-led.sh \
+            file://boot-status-led.service \
+          "
+
+do_install() {
+    install -d ${D}${bindir}
+    install -m 0755 ${WORKDIR}/boot-status-led.sh ${D}${bindir}/
+
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/boot-status-led.service ${D}${systemd_system_unitdir}
+}
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "boot-status-led.service"