summaryrefslogtreecommitdiff
path: root/meta-quanta/meta-gbs/recipes-gbs/boot-status-led
diff options
context:
space:
mode:
Diffstat (limited to 'meta-quanta/meta-gbs/recipes-gbs/boot-status-led')
-rw-r--r--meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.service13
-rw-r--r--meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh50
-rw-r--r--meta-quanta/meta-gbs/recipes-gbs/boot-status-led/gbs-boot-status-led.bb25
3 files changed, 88 insertions, 0 deletions
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 000000000..ea44dda2d
--- /dev/null
+++ b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Boot Status LED Manager
+After=xyz.openbmc_project.LED.GroupManager.service
+Wants=xyz.openbmc_project.LED.GroupManager.service
+
+[Service]
+ExecStart=/usr/bin/boot-status-led.sh
+StandardOutput=syslog
+Type=simple
+Restart=yes
+
+[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 000000000..a80082a1c
--- /dev/null
+++ b/meta-quanta/meta-gbs/recipes-gbs/boot-status-led/files/boot-status-led.sh
@@ -0,0 +1,50 @@
+#!/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"
+
+PWR_STATE_SERVICE="xyz.openbmc_project.State.Chassis"
+PWR_STATE_OBJPATH="/xyz/openbmc_project/state/chassis0"
+PWR_STATE_INTERFACE_NAME="xyz.openbmc_project.State.Chassis"
+PWR_STATE_Property="CurrentPowerState"
+
+boot_status=""
+power_state=""
+led_status=""
+
+mapper wait $LED_INACTIVE_OBJPATH
+mapper wait $LED_STANDBY_OBJPATH
+while true; do
+ power_state="$(busctl get-property $PWR_STATE_SERVICE $PWR_STATE_OBJPATH $PWR_STATE_INTERFACE_NAME $PWR_STATE_Property | awk '{print $2}')"
+
+ boot_status="$(busctl get-property $BOOT_SERVICE_NAME $BOOT_STATUS_OBJPATH $BOOT_INTERFACE_NAME $BOOT_Property | awk '{print $2}')"
+
+ if [[ $power_state != "\"xyz.openbmc_project.State.Chassis.PowerState.On\"" ]];then
+ if [[ $led_status != "OFF" ]];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 false
+ led_status="OFF"
+ fi
+ continue
+ else
+ if [[ $boot_status != "\"Standby\"" ]] && [[ $led_status != "BLINKING" ]];then
+ busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b true
+ led_status="BLINKING"
+ elif [[ $boot_status == "\"Standby\"" ]] && [[ $led_status != "ON" ]];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
+ led_status="ON"
+ fi
+ 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 000000000..61c6ed407
--- /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"