blob: 5e342131118624937606cd01143f8e115c92a63d [file] [log] [blame]
#!/bin/sh -ue
# Copyright (c) 2010 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.
#
# A script to mark the current kernel partition as successfully booted.
# Load functions and constants for chromeos-install.
. "$(dirname "$0")/chromeos-common.sh" || exit 1
if [ "0" = $(id -u) ]; then
local sudo=""
else
local sudo=sudo
fi
# Extract the kernel partition's UniqueGuid from the command line.
guid=$(sed 's/.*kern_guid=\([0-9a-fA-F-]\+\).*/\1/' /proc/cmdline)
# Look through all the known devices to find that one partition.
kern_dev=$($sudo cgpt find -1 -u $guid)
# Split the kernel device in the base device and paritition number.
base_dev=$(get_block_dev_from_partition_dev $kern_dev)
kern_num=$(get_partition_number $kern_dev)
# Mark the kernel as successfully booted (success=1, tries=0).
$sudo cgpt add $base_dev -i $kern_num -S1 -T0
# Mark the kernel as highest priority
$sudo cgpt prioritize $base_dev -i $kern_num
# Run the verified boot debugging tool now, because we won't be able to run it
# manually if there's a problem (no root shell). It leaves a log file that we
# can look at.
$sudo dev_debug_vboot --cleanup
# Run the firmware updater
FIRMWARE_UPDATE_SCRIPT='/usr/sbin/chromeos-firmwareupdate'
if [ -x "$FIRMWARE_UPDATE_SCRIPT" ]; then
"$FIRMWARE_UPDATE_SCRIPT" --mode=bootok
fi