blob: fab12f6be64e792ca2211096872865d2b618ab1f [file] [log] [blame]
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -08001#!/bin/bash
2
Taylor Hutt60da6422011-06-02 13:54:43 -07003# Copyright (c) 2009-2011 The Chromium OS Authors. All rights reserved.
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -08004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Script to update the kernel on a live running ChromiumOS instance.
8
Brian Harringaa13ea42012-03-15 18:31:03 -07009SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
David James359d3e12012-07-10 13:09:48 -070010. "${SCRIPT_ROOT}/common.sh" || exit 1
11. "${SCRIPT_ROOT}/remote_access.sh" || exit 1
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080012
Mandeep Singh Baines2f3b5fc2011-01-14 14:20:12 -080013# Script must be run inside the chroot.
Greg Spencer798d75f2011-02-01 22:04:49 -080014restart_in_chroot_if_needed "$@"
Mandeep Singh Baines2f3b5fc2011-01-14 14:20:12 -080015
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080016DEFINE_string board "" "Override board reported by target"
Olof Johanssonf53fa0d2011-01-26 13:06:46 -080017DEFINE_string device "" "Override boot device reported by target"
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080018DEFINE_string partition "" "Override kernel partition reported by target"
Doug Andersonfcaed8a2014-07-09 11:34:29 -070019DEFINE_string rootoff "" "Override root offset"
Stephen Boydf16cd6b2019-03-08 09:27:10 -080020DEFINE_string rootfs "" "Override rootfs partition reported by target"
Olof Johanssonf53fa0d2011-01-26 13:06:46 -080021DEFINE_string arch "" "Override architecture reported by target"
Nicolas Boichatabdf6642016-07-04 11:30:44 +080022DEFINE_boolean ignore_verity $FLAGS_FALSE "Update kernel even if system is using verity"
Olof Johansson8488f5a2011-04-20 17:27:37 -070023DEFINE_boolean reboot $FLAGS_TRUE "Reboot system after update"
Doug Anderson5a21b442012-12-07 11:47:31 -080024DEFINE_boolean vboot $FLAGS_TRUE "Update the vboot kernel"
Olof Johansson68cbfaf2013-04-23 14:06:28 -070025DEFINE_boolean syslinux $FLAGS_TRUE "Update the syslinux kernel"
Olof Johansson45225c92013-10-15 17:32:48 -070026DEFINE_boolean bootonce $FLAGS_FALSE "Mark kernel partition as boot once"
Olof Johansson4a7b2882013-10-16 11:59:58 -070027DEFINE_boolean remote_bootargs $FLAGS_FALSE "Use bootargs from running kernel on target"
Nicolas Boichata595deb2017-02-07 18:53:44 +080028DEFINE_boolean firmware $FLAGS_FALSE "Also update firmwares (/lib/firmware)"
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080029
Doug Anderson549f3b52013-09-26 14:46:18 -070030ORIG_ARGS=("$@")
31
Mandeep Singh Baines2f3b5fc2011-01-14 14:20:12 -080032# Parse command line.
33FLAGS "$@" || exit 1
34eval set -- "${FLAGS_ARGV}"
35
36# Only now can we die on error. shflags functions leak non-zero error codes,
Brian Harring7f175a52012-03-02 05:37:00 -080037# so will die prematurely if 'switch_to_strict_mode' is specified before now.
38switch_to_strict_mode
Mandeep Singh Baines2f3b5fc2011-01-14 14:20:12 -080039
Mike Frysinger6b1abb22012-05-11 13:44:06 -040040cleanup() {
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080041 cleanup_remote_access
42 rm -rf "${TMP}"
43}
44
Mike Frysinger6b1abb22012-05-11 13:44:06 -040045learn_device() {
Olof Johanssonf53fa0d2011-01-26 13:06:46 -080046 [ -n "${FLAGS_device}" ] && return
47 remote_sh df /mnt/stateful_partition
48 FLAGS_device=$(echo "${REMOTE_OUT}" | awk '/dev/ {print $1}' | sed s/1\$//)
49 info "Target reports root device is ${FLAGS_device}"
50}
51
Ben Zhang15fa4b12017-06-19 20:02:57 -070052# Delete the fixed numbers after R65 when we don't care about <R57 upgrades.
53load_default_partition_numbers() {
54 PARTITION_NUM_KERN_A=2
55 PARTITION_NUM_ROOT_A=3
56 PARTITION_NUM_KERN_B=4
57 PARTITION_NUM_EFI_SYSTEM=12
58}
59
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080060# Ask the target what the kernel partition is
Mike Frysinger6b1abb22012-05-11 13:44:06 -040061learn_partition_and_ro() {
Mandeep Singh Bainese39579a2011-03-04 15:58:57 -080062 ! remote_sh rootdev
Paul Taysoma64d9db2012-09-21 13:30:43 -070063 if [ "${REMOTE_OUT%%-*}" == "/dev/dm" ]; then
64 remote_sh rootdev -s
Olof Johansson8488f5a2011-04-20 17:27:37 -070065 REMOTE_VERITY=${FLAGS_TRUE}
Nicolas Boichatabdf6642016-07-04 11:30:44 +080066 if [[ ${FLAGS_ignore_verity} -eq ${FLAGS_TRUE} ]]; then
67 warn "System is using verity: not updating firmware/modules"
68 else
69 warn "System is using verity: First remove rootfs verification using"
70 warn "/usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification"
71 warn "on the DUT, or add --ignore_verity parameter to this command."
Brian Norrised751572018-03-30 13:48:43 -070072 die_notrace
Nicolas Boichatabdf6642016-07-04 11:30:44 +080073 fi
Olof Johansson8488f5a2011-04-20 17:27:37 -070074 else
75 REMOTE_VERITY=${FLAGS_FALSE}
76 info "System is not using verity: updating firmware and modules"
Mandeep Singh Bainese39579a2011-03-04 15:58:57 -080077 fi
Stephen Boydf16cd6b2019-03-08 09:27:10 -080078 if [[ -z "${FLAGS_rootfs}" ]]; then
79 FLAGS_rootfs="${REMOTE_OUT}"
80 fi
81 # If rootfs is for different partition than we're currently running on
82 # mount it manually to update the right modules, firmware, etc.
83 REMOTE_NEEDS_ROOTFS_MOUNTED=${FLAGS_FALSE}
84 if [[ "${REMOTE_OUT}" != "${FLAGS_rootfs}" ]]; then
85 REMOTE_NEEDS_ROOTFS_MOUNTED=${FLAGS_TRUE}
86 fi
Olof Johansson4996bfb2013-11-13 12:58:52 -080087 [ -n "${FLAGS_partition}" ] && return
Steven 'Steve' Kendall019f38f2016-06-09 12:43:28 -040088 if [ "${REMOTE_OUT}" == "${FLAGS_device}${PARTITION_NUM_ROOT_A}" ]; then
89 FLAGS_partition="${FLAGS_device}${PARTITION_NUM_KERN_A}"
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080090 else
Steven 'Steve' Kendall019f38f2016-06-09 12:43:28 -040091 FLAGS_partition="${FLAGS_device}${PARTITION_NUM_KERN_B}"
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080092 fi
93 if [ -z "${FLAGS_partition}" ]; then
Brian Norrised751572018-03-30 13:48:43 -070094 die_notrace "Partition required"
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -080095 fi
Doug Anderson5a21b442012-12-07 11:47:31 -080096 if [ ${REMOTE_VERITY} -eq ${FLAGS_TRUE} ]; then
97 info "Target reports kernel partition is ${FLAGS_partition}"
98 if [ ${FLAGS_vboot} -eq ${FLAGS_FALSE} ]; then
Brian Norrised751572018-03-30 13:48:43 -070099 die_notrace "Must update vboot when target is using verity"
Doug Anderson5a21b442012-12-07 11:47:31 -0800100 fi
101 fi
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -0800102}
103
Olof Johansson4a7b2882013-10-16 11:59:58 -0700104get_bootargs() {
Mike Frysingerd4b6f952017-04-10 16:42:17 -0400105 local local_config="${SRC_ROOT}/build/images/${FLAGS_board}/latest/config.txt"
106
107 # Autodetect by default. https://crbug.com/316239
108 # This isn't quite right if people use --noremote_bootargs, but that's not
109 # a scenario people do today, so we won't worry about it.
110 if [[ ${FLAGS_remote_bootargs} -eq ${FLAGS_FALSE} && \
111 ! -e "${local_config}" ]]; then
112 warn "Local kernel config does not exist: ${local_config}"
113 FLAGS_remote_bootargs=${FLAGS_TRUE}
114 fi
115
Olof Johansson4a7b2882013-10-16 11:59:58 -0700116 if [ ${FLAGS_remote_bootargs} -eq ${FLAGS_TRUE} ] ; then
117 info "Using remote bootargs"
Peter Shih0bacb332018-11-27 16:14:06 +0800118 remote_sh cat /proc/cmdline
119 # Remove multiple instances of cros_secure, https://crbug.com/907772
120 echo "${REMOTE_OUT}" | sed -E 's/\b(cros_secure )+/cros_secure /g'
Olof Johansson4a7b2882013-10-16 11:59:58 -0700121 else
Doug Andersonfcaed8a2014-07-09 11:34:29 -0700122 if [ -n "${FLAGS_rootoff}" ]; then
Mike Frysingerd4b6f952017-04-10 16:42:17 -0400123 sed "s/PARTNROFF=1/PARTNROFF=${FLAGS_rootoff}/" "${local_config}"
Doug Andersonfcaed8a2014-07-09 11:34:29 -0700124 else
Mike Frysingerd4b6f952017-04-10 16:42:17 -0400125 cat "${local_config}"
Doug Andersonfcaed8a2014-07-09 11:34:29 -0700126 fi
Olof Johansson4a7b2882013-10-16 11:59:58 -0700127 fi
128}
129
Mike Frysinger6b1abb22012-05-11 13:44:06 -0400130make_kernelimage() {
Tom Wai-Hong Tam6b50a072011-05-25 17:00:15 +0800131 local bootloader_path
132 local kernel_image
Olof Johansson4a7b2882013-10-16 11:59:58 -0700133 local config_path="$(mktemp /tmp/config.txt.XXXXX)"
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800134 if [[ "${FLAGS_arch}" == "arm" ]]; then
Taylor Hutt60da6422011-06-02 13:54:43 -0700135 name="bootloader.bin"
136 bootloader_path="${SRC_ROOT}/build/images/${FLAGS_board}/latest/${name}"
Mike Frysinger085c5d92017-08-16 17:29:12 -0400137 # If there is no local bootloader stub, create a dummy file. This matches
138 # build_kernel_image.sh. If we wanted to be super paranoid, we could copy
139 # and extract it from the remote image, if it had one.
140 if [[ ! -e "${bootloader_path}" ]]; then
141 warn "Bootloader does not exist; creating a stub: ${bootloader_path}"
142 mkdir -p "${bootloader_path%/*}"
143 truncate -s 512 "${bootloader_path}"
144 fi
Tom Wai-Hong Tam6b50a072011-05-25 17:00:15 +0800145 kernel_image="/build/${FLAGS_board}/boot/vmlinux.uimg"
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800146 else
Tom Wai-Hong Tam6b50a072011-05-25 17:00:15 +0800147 bootloader_path="/lib64/bootstub/bootstub.efi"
148 kernel_image="/build/${FLAGS_board}/boot/vmlinuz"
149 fi
Olof Johansson4a7b2882013-10-16 11:59:58 -0700150 get_bootargs > "${config_path}"
Kees Cook43a32132011-10-18 13:17:11 -0700151 vbutil_kernel --pack $TMP/new_kern.bin \
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800152 --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
153 --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
154 --version 1 \
Olof Johansson4a7b2882013-10-16 11:59:58 -0700155 --config ${config_path} \
Tom Wai-Hong Tam6b50a072011-05-25 17:00:15 +0800156 --bootloader "${bootloader_path}" \
157 --vmlinuz "${kernel_image}" \
158 --arch "${FLAGS_arch}"
Olof Johansson4a7b2882013-10-16 11:59:58 -0700159 rm "${config_path}"
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800160}
161
Edward Hyunkoo Jeea979a902017-03-08 13:44:26 -0800162copy_kernelmodules() {
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800163 local basedir="$1" # rootfs directory (could be in /tmp) or empty string
Edward Hyunkoo Jeea979a902017-03-08 13:44:26 -0800164 echo "copying modules"
165 local modules_dir=/build/"${FLAGS_board}"/lib/modules/
166 if [ ! -d "${modules_dir}" ]; then
167 info "No modules. Skipping."
168 return
169 fi
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800170 remote_send_to "${modules_dir}" "${basedir}"/lib/modules
Edward Hyunkoo Jeea979a902017-03-08 13:44:26 -0800171 local kernel_release
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800172 remote_sh "cd ${basedir}/lib/modules; echo *"
Edward Hyunkoo Jeea979a902017-03-08 13:44:26 -0800173 for kernel_release in "${REMOTE_OUT}"; do
174 local system_map="${modules_dir}"/"${kernel_release}"/build/System.map
175 if [ -r "${system_map}" ]; then
176 remote_sh mktemp -d /tmp/update_kernel_system_map_"${kernel_release}".XXXXXX
177 local temp_dir="${REMOTE_OUT}"
178 remote_cp_to "${system_map}" "${temp_dir}"
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800179 local b_opt
180 if [ -n "${basedir}" ]; then
181 b_opt="-b ${basedir}"
182 fi
183 remote_sh depmod "${b_opt}" -ae \
184 -F "${temp_dir}"/System.map "${kernel_release}"
Edward Hyunkoo Jeea979a902017-03-08 13:44:26 -0800185 remote_sh rm -rf "${temp_dir}"
186 fi
187 done
188}
189
Mike Frysinger6b1abb22012-05-11 13:44:06 -0400190copy_kernelimage() {
Doug Andersonadf8a002012-12-17 11:40:34 -0800191 remote_sh dd of="${FLAGS_partition}" bs=4K < "${TMP}/new_kern.bin"
Olof Johansson8488f5a2011-04-20 17:27:37 -0700192}
193
Jonathan Kliegman775bc8e2012-08-14 12:30:49 -0400194check_kernelbuildtime() {
195 local version=$(readlink "/build/${FLAGS_board}/boot/vmlinuz" | cut -d- -f2-)
196 local build_dir="/build/${FLAGS_board}/lib/modules/${version}/build"
197 if [ "${build_dir}/Makefile" -nt "/build/${FLAGS_board}/boot/vmlinuz" ]; then
198 warn "Your build directory has been built more recently than"
199 warn "the installed kernel being updated to. Did you forget to"
200 warn "run 'cros_workon_make chromeos-kernel --install'?"
201 fi
202}
203
Olof Johansson45225c92013-10-15 17:32:48 -0700204mark_boot_once() {
205 local idx=${FLAGS_partition##*[^0-9]}
Chirantan Ekbotef25b4402014-05-06 12:42:18 -0700206 remote_sh cgpt add -i ${idx} -S 0 -T 1 -P 15 ${FLAGS_device%p}
Olof Johansson45225c92013-10-15 17:32:48 -0700207}
208
Olof Johansson68cbfaf2013-04-23 14:06:28 -0700209update_syslinux_kernel() {
210 # ARM does not have the syslinux directory, so skip it when the
Evan Greenfd9652b2018-10-01 13:36:02 -0700211 # partition is missing, the file system fails to mount, or the syslinux
212 # vmlinuz target is missing.
Olof Johansson68cbfaf2013-04-23 14:06:28 -0700213 echo "updating syslinux kernel"
Steven 'Steve' Kendall019f38f2016-06-09 12:43:28 -0400214 remote_sh grep $(echo ${FLAGS_device}${PARTITION_NUM_EFI_SYSTEM} | cut -d/ -f3) /proc/partitions
Olof Johansson68cbfaf2013-04-23 14:06:28 -0700215 if [ $(echo "$REMOTE_OUT" | wc -l) -eq 1 ]; then
Steven 'Steve' Kendall019f38f2016-06-09 12:43:28 -0400216 remote_sh mkdir -p /tmp/${PARTITION_NUM_EFI_SYSTEM}
Evan Greenfd9652b2018-10-01 13:36:02 -0700217 if remote_sh mount ${FLAGS_device}${PARTITION_NUM_EFI_SYSTEM} \
218 /tmp/${PARTITION_NUM_EFI_SYSTEM}; then
Olof Johansson68cbfaf2013-04-23 14:06:28 -0700219
Evan Greenfd9652b2018-10-01 13:36:02 -0700220 if [ "$FLAGS_partition" = "${FLAGS_device}${PARTITION_NUM_KERN_A}" ]; then
221 target="/tmp/${PARTITION_NUM_EFI_SYSTEM}/syslinux/vmlinuz.A"
222 else
223 target="/tmp/${PARTITION_NUM_EFI_SYSTEM}/syslinux/vmlinuz.B"
224 fi
225 remote_sh "test ! -f $target || cp /boot/vmlinuz $target"
226
227 remote_sh umount /tmp/${PARTITION_NUM_EFI_SYSTEM}
Olof Johansson68cbfaf2013-04-23 14:06:28 -0700228 fi
Steven 'Steve' Kendall019f38f2016-06-09 12:43:28 -0400229 remote_sh rmdir /tmp/${PARTITION_NUM_EFI_SYSTEM}
Olof Johansson68cbfaf2013-04-23 14:06:28 -0700230 fi
231}
232
Doug Anderson549f3b52013-09-26 14:46:18 -0700233multi_main() {
234 local host
235
236 IFS=","
237 for host in ${FLAGS_remote}; do
238 "$0" "${ORIG_ARGS[@]}" --remote="${host}" \
239 |& sed "s/^/${V_BOLD_YELLOW}${host}: ${V_VIDOFF}/" &
240 done
241 wait
242}
243
Mike Frysinger6b1abb22012-05-11 13:44:06 -0400244main() {
Doug Anderson549f3b52013-09-26 14:46:18 -0700245 # If there are commas in the --remote, run the script in parallel.
246 if [[ ${FLAGS_remote} == *,* ]]; then
247 multi_main
248 return $?
249 fi
250
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -0800251 trap cleanup EXIT
252
Kees Cook43a32132011-10-18 13:17:11 -0700253 TMP=$(mktemp -d /tmp/update_kernel.XXXXXX)
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -0800254
255 remote_access_init
256
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800257 learn_arch
258
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -0800259 learn_board
260
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800261 learn_device
262
Ian Coolidgec3d5d912017-03-07 14:21:28 -0800263 learn_partition_layout
Ben Zhang15fa4b12017-06-19 20:02:57 -0700264 if [[ -z "${PARTITION_NUM_KERN_A}" ]]; then
265 info "Target has no partition number info, use default instead"
266 load_default_partition_numbers
267 fi
Ian Coolidgec3d5d912017-03-07 14:21:28 -0800268
Olof Johansson8488f5a2011-04-20 17:27:37 -0700269 learn_partition_and_ro
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800270
Brian Norris9774b0d2017-06-15 13:44:26 -0700271 if ! remote_sh "test -e '${FLAGS_partition}'"; then
272 die_notrace "Could not find kernel partition on DUT; path='${FLAGS_partition}'"
273 fi
274
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -0800275 remote_sh uname -r -v
276
277 old_kernel="${REMOTE_OUT}"
278
Jonathan Kliegman775bc8e2012-08-14 12:30:49 -0400279 check_kernelbuildtime
280
Doug Anderson5a21b442012-12-07 11:47:31 -0800281 if [ ${FLAGS_vboot} -eq ${FLAGS_TRUE} ]; then
282 make_kernelimage
283 fi
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -0800284
Olof Johansson8488f5a2011-04-20 17:27:37 -0700285 if [[ ${REMOTE_VERITY} -eq ${FLAGS_FALSE} ]]; then
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800286 local remote_basedir
287 if [[ ${REMOTE_NEEDS_ROOTFS_MOUNTED} -eq ${FLAGS_TRUE} ]]; then
288 remote_sh mktemp -d /tmp/"${FLAGS_rootfs#$FLAGS_device}".XXXXXX
289 remote_basedir="${REMOTE_OUT}"
290 remote_sh mount "${FLAGS_rootfs}" "${remote_basedir}"
291 else
292 remote_sh mount -o remount,rw /
293 fi
Kees Cook7d7d2ef2011-10-18 13:12:12 -0700294 echo "copying kernel"
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800295 remote_send_to /build/"${FLAGS_board}"/boot/ "${remote_basedir}"/boot/
Kees Cook7d7d2ef2011-10-18 13:12:12 -0700296
Olof Johansson68cbfaf2013-04-23 14:06:28 -0700297 if [ ${FLAGS_syslinux} -eq ${FLAGS_TRUE} ]; then
298 update_syslinux_kernel
Kees Cook7d7d2ef2011-10-18 13:12:12 -0700299 fi
Olof Johansson9a83e4e2012-08-17 02:45:12 -0700300
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800301 copy_kernelmodules "${remote_basedir}"
Olof Johansson9a83e4e2012-08-17 02:45:12 -0700302
Nicolas Boichata595deb2017-02-07 18:53:44 +0800303 if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
304 echo "copying firmware"
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800305 remote_send_to /build/"${FLAGS_board}"/lib/firmware/ \
306 "${remote_basedir}"/lib/firmware/
Nicolas Boichata595deb2017-02-07 18:53:44 +0800307 else
308 info "Skipping update of firmware (per request)."
309 fi
Stephen Boydf16cd6b2019-03-08 09:27:10 -0800310 if [[ ${REMOTE_NEEDS_ROOTFS_MOUNTED} -eq ${FLAGS_TRUE} ]]; then
311 remote_sh umount "${remote_basedir}"
312 remote_sh rmdir "${remote_basedir}"
313 fi
Olof Johansson5a46bfb2010-12-22 12:14:21 -0800314 fi
315
Doug Anderson5a21b442012-12-07 11:47:31 -0800316 if [ ${FLAGS_vboot} -eq ${FLAGS_TRUE} ]; then
317 info "Copying vboot kernel image"
318 copy_kernelimage
319 else
320 info "Skipping update of vboot (per request)"
321 fi
Olof Johansson8488f5a2011-04-20 17:27:37 -0700322
Olof Johansson45225c92013-10-15 17:32:48 -0700323 if [ ${FLAGS_bootonce} -eq ${FLAGS_TRUE} ]; then
324 info "Marking kernel partition ${FLAGS_partition} as boot once"
325 mark_boot_once
326 fi
327
Jonathan Kliegmand6f3d072012-07-12 12:45:33 -0400328 # An early kernel panic can prevent the normal sync on reboot. Explicitly
329 # sync for safety to avoid random file system corruption.
330 remote_sh sync
331
Doug Andersonb2fe4652012-12-07 17:33:56 -0800332 if [ ${FLAGS_reboot} -eq ${FLAGS_TRUE} ]; then
Olof Johansson8488f5a2011-04-20 17:27:37 -0700333 remote_reboot
334
335 remote_sh uname -r -v
336 info "old kernel: ${old_kernel}"
337 info "new kernel: ${REMOTE_OUT}"
338 else
339 info "Not rebooting (per request)"
340 fi
Mandeep Singh Bainesa63cd2d2010-12-02 11:58:26 -0800341}
342
Olof Johanssonf53fa0d2011-01-26 13:06:46 -0800343main "$@"