blob: a80082a1cdad7fdb2dc759dc1d60b31dffacdd66 [file] [log] [blame]
George Hungce97fb12020-05-13 17:25:22 +08001#!/bin/bash
2
George Hung76c47ec2021-08-19 02:27:09 +00003BOOT_SERVICE_NAME="xyz.openbmc_project.State.Host"
George Hungce97fb12020-05-13 17:25:22 +08004BOOT_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 Hung76c47ec2021-08-19 02:27:09 +000014PWR_STATE_SERVICE="xyz.openbmc_project.State.Chassis"
George Hung0d7b79c2020-09-03 08:53:35 +080015PWR_STATE_OBJPATH="/xyz/openbmc_project/state/chassis0"
16PWR_STATE_INTERFACE_NAME="xyz.openbmc_project.State.Chassis"
17PWR_STATE_Property="CurrentPowerState"
18
George Hungce97fb12020-05-13 17:25:22 +080019boot_status=""
George Hung0d7b79c2020-09-03 08:53:35 +080020power_state=""
21led_status=""
George Hungce97fb12020-05-13 17:25:22 +080022
23mapper wait $LED_INACTIVE_OBJPATH
24mapper wait $LED_STANDBY_OBJPATH
25while true; do
George Hung0d7b79c2020-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 Hungce97fb12020-05-13 17:25:22 +080027
George Hung0d7b79c2020-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 Hungce97fb12020-05-13 17:25:22 +080046 fi
47 sleep 1
48done
49
50exit 0