blob: ec3e9f406ef098bec84eb85be313363b93caaa0f [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.
#### CATEGORY=Other
### build a fuchsia persistent disk
## usage: fx make-fuchsia-vol [-include-keys]
## -include-keys add the keys from ~/.ssh/fuchsia_authorized_keys
## to the Zircon ZBI as authorized_keys
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../lib/vars.sh || exit $?
fx-config-read
fwd_args=()
include_keys=0
while (($#)); do
case "$1" in
-include-keys)
include_keys=1
;;
*)
fwd_args+=("$1")
;;
esac
shift
done
keys_args=()
if [ "${include_keys}" == 1 ]; then
authkeys_path="$(get-ssh-authkeys)" || {
fx-error "Cannot continue without a valid authorized keys file."
exit 1
}
fx-zbi -o "${FUCHSIA_BUILD_DIR}/fuchsia-extra-keys.zbi" \
"${FUCHSIA_BUILD_DIR}/$(fx-get-zbi zircon-a)" --replace \
--entry "data/ssh/authorized_keys=${authkeys_path}"
keys_args+=(--zbi "${FUCHSIA_BUILD_DIR}/fuchsia-extra-keys.zbi")
fi
"${FUCHSIA_BUILD_DIR}/host-tools/make-fuchsia-vol" "${keys_args[@]}" "${fwd_args[@]}"