eval "$1"
}
+# Run novaboot with the same configuration as specified in
+# ~/.novaboot-shell, but allow the caller to extend of override them
+# via parameters of this function.
+run_novaboot() {
+ nbscript=$1
+ shift
+ OLD_IFS=$IFS
+ # Split $target_config below by newlines, not by words
+ IFS="
+"
+ novaboot "$nbscript" $target_config --server="$HOME/tftproot" --reset-cmd="${reset_cmd:?}" --remote-cmd="${console_cmd:?}" "$@"
+ IFS=$OLD_IFS
+}
+
# run_subcommand should be called only after permission checks and/or locking
run_subcommand() {
read_config
As F<novaboot> (client) always uses the C<console> command to connect
to the console, C<default_cmd> can be used to boot the target with
some default configuration for users who do not use F<novaboot> client
-to boot their own configuration. For example, C<default_cmd> can be
-set to execute a novaboot script.
+to boot their own configuration.
-In other words, C<ssh board@host> boots the board in the default
-configuration, whereas C<novaboot --ssh=board@host ...> boots the
+In other words, C<ssh board@host> will boot the board in some default
+configuration, whereas C<novaboot --ssh=board@host ...> will boot the
board as configured in C<...>.
+Often, it is desired to run F<novaboot> on the server to boot the
+default configuration. To make this easier to configure, the
+C<default_cmd> can be set to:
+
+ run_novaboot <nbscript> [<extra args>...]
+
+This command will execute C<novaboot> with the F<\<nbscript>> script
+as an argument and passes it a few switches with values from the
+F<$HOME/.novaboot-shell> configuration file. Specifically, it will
+pass all switches from the C<target_config> variable, C<--reset-cmd>
+and C<--remote-cmd> switches with the values of C<reset_cmd> and
+C<console_cmd> variables respectively (see above) and C<--server>
+switch.
+
+Therefore, to boot the default configuration as specified in the
+F<default_boot> script, it is sufficient to set C<default_cmd> to:
+
+ run_novaboot ./default_boot --interactive
+
+To have different default configuration for different users, one can
+use the C<$NB_USER> variable as outlined above. The simplest example
+is perhaps this command:
+
+ run_novaboot ./default_boot-"$NB_USER" --interactive
+
=back
=head1 AUTHORS
WVPASS run_server console | WVPASS grep -F 'Hello console'
)
+WVSTART "default_cmd can be set to run_novaboot"
+(
+ export NOVABOOT_SHELL_CONFIG="./.novaboot-shell"
+ cat <<EOF > default_nb_script
+run echo "Hello default_nb_script"
+EOF
+ cat <<'EOF' > $NOVABOOT_SHELL_CONFIG
+default_cmd='run_novaboot default_nb_script --scriptmod=s/default_nb_script/default_nb_script_mod/'
+console_cmd='while sleep 0.01; do echo "Hello console"; done'
+reset_cmd='echo "Hello reset"'
+target_config="\
+--name=some name with spaces and hash #
+--exiton=Hello console
+"
+EOF
+ WVPASS run_server | (
+ stdout=$(cat)
+ WVPASS grep -F 'Hello default_nb_script' <<<"$stdout"
+ WVPASS grep -F 'Hello default_nb_script_mod' <<<"$stdout"
+ WVPASS grep -F 'Hello console' <<<"$stdout"
+ )
+)
+
WVSTART 'Second connection to console prints queue'
coproc console1 { exec_server console; }
WVPASS sed -e '/novaboot-shell: Connected/q0' -e '3q1' <&${console1[0]}