summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-core/ac-boot-check/ac-boot-check/ac-boot-check.sh
blob: bf537748227ccc924e07cacdc63bcb1a9d16c9a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

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"

source /etc/os-release

echo "VERSION INFO - BMC - ${VERSION_ID}"