blob: a80082a1cdad7fdb2dc759dc1d60b31dffacdd66 [file] [log] [blame]
George Hung961e0f52020-05-13 17:25:22 +08001#!/bin/bash
2
3BOOT_SERVICE_NAME="xyz.openbmc_project.State.Host"
4BOOT_STATUS_OBJPATH="/xyz/openbmc_project/state/os"
5BOOT_INTERFACE_NAME="xyz.openbmc_project.State.OperatingSystem.Status"
6BOOT_Property="OperatingSystemState"
7
8LED_SERVICE_NAME="xyz.openbmc_project.LED.GroupManager"
9LED_INACTIVE_OBJPATH="/xyz/openbmc_project/led/groups/boot_status_inactive"
10LED_STANDBY_OBJPATH="/xyz/openbmc_project/led/groups/boot_status_standby"
11LED_INTERFACE_NAME="xyz.openbmc_project.Led.Group"
12LED_Property="Asserted"
13
George Hungd967cf62020-09-03 08:53:35 +080014PWR_STATE_SERVICE="xyz.openbmc_project.State.Chassis"
15PWR_STATE_OBJPATH="/xyz/openbmc_project/state/chassis0"
16PWR_STATE_INTERFACE_NAME="xyz.openbmc_project.State.Chassis"
17PWR_STATE_Property="CurrentPowerState"
18
George Hung961e0f52020-05-13 17:25:22 +080019boot_status=""
George Hungd967cf62020-09-03 08:53:35 +080020power_state=""
21led_status=""
George Hung961e0f52020-05-13 17:25:22 +080022
23mapper wait $LED_INACTIVE_OBJPATH
24mapper wait $LED_STANDBY_OBJPATH
25while true; do
George Hungd967cf62020-09-03 08:53:35 +080026 power_state="$(busctl get-property $PWR_STATE_SERVICE $PWR_STATE_OBJPATH $PWR_STATE_INTERFACE_NAME $PWR_STATE_Property | awk '{print $2}')"
George Hung961e0f52020-05-13 17:25:22 +080027
George Hungd967cf62020-09-03 08:53:35 +080028 boot_status="$(busctl get-property $BOOT_SERVICE_NAME $BOOT_STATUS_OBJPATH $BOOT_INTERFACE_NAME $BOOT_Property | awk '{print $2}')"
29
30 if [[ $power_state != "\"xyz.openbmc_project.State.Chassis.PowerState.On\"" ]];then
31 if [[ $led_status != "OFF" ]];then
32 busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b false
33 busctl set-property $LED_SERVICE_NAME $LED_STANDBY_OBJPATH $LED_INTERFACE_NAME $LED_Property b false
34 led_status="OFF"
35 fi
36 continue
37 else
38 if [[ $boot_status != "\"Standby\"" ]] && [[ $led_status != "BLINKING" ]];then
39 busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b true
40 led_status="BLINKING"
41 elif [[ $boot_status == "\"Standby\"" ]] && [[ $led_status != "ON" ]];then
42 busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b false
43 busctl set-property $LED_SERVICE_NAME $LED_STANDBY_OBJPATH $LED_INTERFACE_NAME $LED_Property b true
44 led_status="ON"
45 fi
George Hung961e0f52020-05-13 17:25:22 +080046 fi
47 sleep 1
48done
49
50exit 0