blob: 367c548d48ac75668e06ec92110012e0ac02038e [file] [log] [blame]
#!/bin/bash
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
### reboot a target fuchsia system
## usage: fx reboot [-r|--recovery] [-b|--bootloader] [HOST]
## -r|--recovery Reboot into recovery image
## -b|--bootloader Reboot into bootloader
## HOST Fuchsia link-local name of the device. If not
## specified, will connect to the only available
## device on the link-local network.
set -e
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/lib/vars.sh
fx-config-read
function usage() {
fx-command-help
}
reboot_type="reboot"
while [[ "$1" =~ ^- ]]; do
case "$1" in
-h|--help)
usage
;;
-r|--recovery)
reboot_type="reboot-recovery"
;;
-b|--bootloader)
reboot_type="reboot-bootloader"
;;
*)
break
esac
shift
done
if [[ $# -gt 1 ]]; then
usage
exit 1
fi
# Add timeout for OS X users so they can click the network connection warning
# dialog.
if [[ "$(uname -s)" = "Darwin" ]]; then
timeout_flag="--timeout=3000"
else
timeout_flag="--nowait"
fi
host=${1:-":"}
echo "Rebooting system..."
"${ZIRCON_TOOLS_DIR}/netruncmd" "${timeout_flag}" "${host}" "dm ${reboot_type}"