George Hung | ce97fb1 | 2020-05-13 17:25:22 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
George Hung | 76c47ec | 2021-08-19 02:27:09 +0000 | [diff] [blame] | 3 | BOOT_SERVICE_NAME="xyz.openbmc_project.State.Host" |
George Hung | ce97fb1 | 2020-05-13 17:25:22 +0800 | [diff] [blame] | 4 | BOOT_STATUS_OBJPATH="/xyz/openbmc_project/state/os" |
| 5 | BOOT_INTERFACE_NAME="xyz.openbmc_project.State.OperatingSystem.Status" |
| 6 | BOOT_Property="OperatingSystemState" |
| 7 | |
| 8 | LED_SERVICE_NAME="xyz.openbmc_project.LED.GroupManager" |
| 9 | LED_INACTIVE_OBJPATH="/xyz/openbmc_project/led/groups/boot_status_inactive" |
| 10 | LED_STANDBY_OBJPATH="/xyz/openbmc_project/led/groups/boot_status_standby" |
| 11 | LED_INTERFACE_NAME="xyz.openbmc_project.Led.Group" |
| 12 | LED_Property="Asserted" |
| 13 | |
George Hung | 76c47ec | 2021-08-19 02:27:09 +0000 | [diff] [blame] | 14 | PWR_STATE_SERVICE="xyz.openbmc_project.State.Chassis" |
George Hung | 0d7b79c | 2020-09-03 08:53:35 +0800 | [diff] [blame] | 15 | PWR_STATE_OBJPATH="/xyz/openbmc_project/state/chassis0" |
| 16 | PWR_STATE_INTERFACE_NAME="xyz.openbmc_project.State.Chassis" |
| 17 | PWR_STATE_Property="CurrentPowerState" |
| 18 | |
George Hung | ce97fb1 | 2020-05-13 17:25:22 +0800 | [diff] [blame] | 19 | boot_status="" |
George Hung | 0d7b79c | 2020-09-03 08:53:35 +0800 | [diff] [blame] | 20 | power_state="" |
| 21 | led_status="" |
George Hung | ce97fb1 | 2020-05-13 17:25:22 +0800 | [diff] [blame] | 22 | |
| 23 | mapper wait $LED_INACTIVE_OBJPATH |
| 24 | mapper wait $LED_STANDBY_OBJPATH |
| 25 | while true; do |
George Hung | 0d7b79c | 2020-09-03 08:53:35 +0800 | [diff] [blame] | 26 | power_state="$(busctl get-property $PWR_STATE_SERVICE $PWR_STATE_OBJPATH $PWR_STATE_INTERFACE_NAME $PWR_STATE_Property | awk '{print $2}')" |
George Hung | ce97fb1 | 2020-05-13 17:25:22 +0800 | [diff] [blame] | 27 | |
George Hung | 0d7b79c | 2020-09-03 08:53:35 +0800 | [diff] [blame] | 28 | 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 Hung | ce97fb1 | 2020-05-13 17:25:22 +0800 | [diff] [blame] | 46 | fi |
| 47 | sleep 1 |
| 48 | done |
| 49 | |
| 50 | exit 0 |