blob: a5c5dc906215e3ba7eff49f8193f22afd5ed5285 [file] [log] [blame]
#!/bin/bash
#
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# This script uses ectool to send command to EC to cut off the battery power.
#
DISPLAY_MESSAGE="/usr/sbin/display_wipe_message.sh"
modprobe i2c_dev
if (ectool battery | grep -q AC_PRESENT); then
"${DISPLAY_MESSAGE}" "remove_ac"
while (ectool battery | grep -q AC_PRESENT) ; do
sleep 0.5;
done
fi
# Discharge battery to ensure battery capacity in desired range
/usr/sbin/board_discharge_battery.sh
"${DISPLAY_MESSAGE}" "cutting_off"
ectool batterycutoff
sleep 15
"${DISPLAY_MESSAGE}" "cutoff_failed"
sleep 1d
exit 1