blob: 65fc0bc50bd2847901d718a049bfa34f11801fab [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
14dbus_state=0
15boot_status=""
16check_flag=0
17
18mapper wait $LED_INACTIVE_OBJPATH
19mapper wait $LED_STANDBY_OBJPATH
20while true; do
21 boot_status=$(busctl get-property $BOOT_SERVICE_NAME $BOOT_STATUS_OBJPATH $BOOT_INTERFACE_NAME $BOOT_Property | awk '{print $2}')
22
23 if [ $boot_status != "\"Standby\"" ] && [ $check_flag -eq 0 ];then
24 busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b true
25 check_flag=1
26 elif [ $boot_status == "\"Standby\"" ];then
27 busctl set-property $LED_SERVICE_NAME $LED_INACTIVE_OBJPATH $LED_INTERFACE_NAME $LED_Property b false
28 busctl set-property $LED_SERVICE_NAME $LED_STANDBY_OBJPATH $LED_INTERFACE_NAME $LED_Property b true
29 break
30 fi
31 sleep 1
32done
33
34exit 0