summaryrefslogtreecommitdiff
path: root/meta-ampere/meta-common/recipes-ampere/host/ampere-hostctrl/ampere_host_check.sh
blob: e3c83b6a5ea991932c5ec98d201ece8acbd52c47 (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
27
28
29
30
#!/bin/bash

# Check current Host status. Do nothing when the Host is currently ON
st=$(busctl get-property xyz.openbmc_project.State.Host \
	/xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host \
	CurrentHostState | cut -d"." -f6)
if [ "$st" == "Running\"" ]; then
	exit 0
fi

# Time out checking for Host ON is 60s
cnt=60
while [ "$cnt" -gt 0 ];
do
	cnt=$((cnt - 1))
	st=$(busctl call xyz.openbmc_project.State.HostCondition.Gpio0 \
		/xyz/openbmc_project/Gpios/host0 org.freedesktop.DBus.Properties \
		Get ss xyz.openbmc_project.Condition.HostFirmware \
		CurrentFirmwareCondition | cut -d"." -f6)
	if [ "$st" == "Running\"" ]; then
		if command -v ampere_driver_binder.sh;
		then
			ampere_driver_binder.sh
		fi
		exit 0
	fi
	sleep 1
done

exit 1