Initial commit
This commit is contained in:
+59
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage of this utility
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") [on|off|forceoff]";
|
||||
}
|
||||
|
||||
#Check CPU boot done pin drop in 30s
|
||||
timeout=30
|
||||
wait_graceful_off(){
|
||||
echo "Wait for host shutdown in ${timeout}s"
|
||||
while [ "${timeout}" -gt 0 ]; do
|
||||
host_state=$(gpioget --numeric host0-ready)
|
||||
timeout=$((timeout-1))
|
||||
if [ "${host_state}" -eq 0 ]; then
|
||||
echo "Host is graceful off"
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "Host still on, but reach timeout"
|
||||
}
|
||||
|
||||
set_gpio_power_off() {
|
||||
echo "Set GPIO to power off chassis"
|
||||
gpioset --hold-period 50ms -t0 power-chassis-control0=1
|
||||
gpioset --hold-period 50ms -t0 power-chassis-control1=1
|
||||
}
|
||||
|
||||
set_gpio_power_on() {
|
||||
echo "Set GPIO to power on chassis"
|
||||
val=$(gpioget --numeric host0-ready)
|
||||
if [ "$val" == 1 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
gpioset --hold-period 50ms -t0 power-chassis-control0=0
|
||||
gpioset --hold-period 50ms -t0 power-chassis-control1=0
|
||||
|
||||
#Record IPMI power cycle SEL
|
||||
busctl call xyz.openbmc_project.Logging.IPMI \
|
||||
/xyz/openbmc_project/Logging/IPMI \
|
||||
xyz.openbmc_project.Logging.IPMI IpmiSelAdd ssaybq \
|
||||
"Power Cycle" "/xyz/openbmc_project/state/host0" \
|
||||
3 0x01 0xff 0xff true 0x0020
|
||||
}
|
||||
|
||||
if [ "$1" == "on" ]; then
|
||||
set_gpio_power_on
|
||||
elif [ "$1" == "off" ]; then
|
||||
wait_graceful_off
|
||||
set_gpio_power_off
|
||||
elif [ "$1" == "forceoff" ]; then
|
||||
set_gpio_power_off
|
||||
else
|
||||
echo "Invalid parameter"
|
||||
usage
|
||||
fi
|
||||
exit 0
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage of this utility
|
||||
usage() {
|
||||
echo "Usage: $(basename "$0") [reset|gracefuloff]"
|
||||
}
|
||||
|
||||
graceful_off() {
|
||||
echo "Set GPIO to graceful shutdown Host"
|
||||
gpioset --hold-period 50ms -t0 power-button=1
|
||||
sleep 0.1
|
||||
gpioset --hold-period 50ms -t0 power-button=0
|
||||
gpioget power-button >/dev/null 2>&1
|
||||
}
|
||||
|
||||
force_reset() {
|
||||
echo "Set GPIO to reset Host"
|
||||
gpioset --hold-period 50ms -t0 reset-button=0
|
||||
sleep 0.1
|
||||
gpioset --hold-period 50ms -t0 reset-button=1
|
||||
gpioget reset-button >/dev/null 2>&1
|
||||
}
|
||||
|
||||
if [ "$1" == "reset" ]; then
|
||||
force_reset
|
||||
elif [ "$1" == "gracefuloff" ]; then
|
||||
graceful_off
|
||||
else
|
||||
echo "Invalid parameter"
|
||||
usage
|
||||
fi
|
||||
exit 0
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=NCPLite Chassis Power Off
|
||||
Before=phosphor-wait-power-off@%i.service
|
||||
Conflicts=ncplite-chassis-poweron@%i.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=@SBINDIR@/chassis-control off
|
||||
ExecStartPost=/bin/sh -c "busctl call xyz.openbmc_project.Logging.IPMI \
|
||||
/xyz/openbmc_project/Logging/IPMI \
|
||||
xyz.openbmc_project.Logging.IPMI IpmiSelAdd ssaybq \
|
||||
'Power Off' '/xyz/openbmc_project/state/host0' \
|
||||
3 0x00 0xff 0xff true 0x0020"
|
||||
ExecStartPost=/bin/sleep 10
|
||||
SyslogIdentifier=chassis-control
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=NCPLite Chassis Power on
|
||||
Before=phosphor-wait-power-on@%i.service
|
||||
After=obmc-power-start-pre@%i.target
|
||||
Conflicts=ncplite-chassis-poweroff@%i.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=@SBINDIR@/chassis-control on
|
||||
SyslogIdentifier=chassis-control
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=NCPLite Force Reset Host%i
|
||||
Wants=phosphor-reboot-host@%i.service
|
||||
Conflicts=obmc-chassis-poweroff@%i.target
|
||||
OnFailure=obmc-chassis-powerreset@%i.target
|
||||
|
||||
[Service]
|
||||
RemainAfterExit=no
|
||||
Type=oneshot
|
||||
ExecStart=@SBINDIR@/host-control reset
|
||||
ExecStartPost=/bin/sh -c "busctl call xyz.openbmc_project.Logging.IPMI /xyz/openbmc_project/Logging/IPMI xyz.openbmc_project.Logging.IPMI IpmiSelAdd ssaybq 'Reset Button Pressed' '/xyz/openbmc_project/state/chassis0' 3 0x02 0xff 0xff true 0x0020"
|
||||
SyslogIdentifier=host-control
|
||||
|
||||
[Install]
|
||||
WantedBy=obmc-host-force-warm-reboot@%i.target
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=NCPLite Host%i Off
|
||||
Before=obmc-chassis-hard-poweroff@%i.target
|
||||
Before=obmc-chassis-poweroff@%i.target
|
||||
Conflicts=obmc-host-startmin@%i.target
|
||||
OnFailure=obmc-chassis-poweroff@%i.target
|
||||
OnFailureJobMode=flush
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=@SBINDIR@/host-control gracefuloff
|
||||
ExecStartPost=/bin/sh -c "busctl call xyz.openbmc_project.Logging.IPMI \
|
||||
/xyz/openbmc_project/Logging/IPMI \
|
||||
xyz.openbmc_project.Logging.IPMI IpmiSelAdd ssaybq \
|
||||
'Power Button Pressed' '/xyz/openbmc_project/state/chassis0' \
|
||||
3 0x00 0xff 0xff true 0x0020"
|
||||
Reference in New Issue
Block a user