diff options
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-core/ac-boot-check')
-rw-r--r-- | meta-openbmc-mods/meta-common/recipes-core/ac-boot-check/ac-boot-check/ac-boot-check.sh | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-core/ac-boot-check/ac-boot-check/ac-boot-check.sh b/meta-openbmc-mods/meta-common/recipes-core/ac-boot-check/ac-boot-check/ac-boot-check.sh index 38728b512..b9ea1127c 100644 --- a/meta-openbmc-mods/meta-common/recipes-core/ac-boot-check/ac-boot-check/ac-boot-check.sh +++ b/meta-openbmc-mods/meta-common/recipes-core/ac-boot-check/ac-boot-check/ac-boot-check.sh @@ -1,8 +1,23 @@ #!/bin/sh -if [[ `cat /proc/cmdline` =~ "resetreason=0x11" ]] -then - busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/control/host0/ac_boot xyz.openbmc_project.Common.ACBoot ACBoot s "True" -else - busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/control/host0/ac_boot xyz.openbmc_project.Common.ACBoot ACBoot s "False" -fi +bitWiseAnd() { + local IFS='&' + printf "%s\n" "$(( $* ))" +} + +ACBOOT="False" + +while IFS=' ' read -ra OPTIONS; do + for i in "${OPTIONS[@]}"; do + while IFS='=' read option param; do + if [ "resetreason" == "$option" ]; then + if [ $(bitWiseAnd "$param" "0x1") -ne 0 ]; then + ACBOOT="True" + fi + fi + done <<< $i + done +done < /proc/cmdline + +busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/control/host0/ac_boot xyz.openbmc_project.Common.ACBoot ACBoot s "$ACBOOT" + |