run_subcommand() {
read_config
case "$*" in
+ "default")
+ run_console "${default_cmd:-${console_cmd:?}}";;
"console")
run_console "${console_cmd:?}";;
"reset")
case "$1" in
# Commands allowed at any time
- "console"|"") locked $0 console;;
+ "") locked $0 default;;
+ "console") locked $0 console;;
"get-config") read_config && echo -n "${target_config}"; exit;;
"add-key") shift; add_key "$@"; exit;;
"shell") exec_shell; exit;;
sharing, which is what L<novaboot(1)> uses (see I<-M> and I<-S> in
L<ssh(1)>).
-This is the default command when no command is specified on command
-line.
+This is the default command when no command is specified on the
+command line and C<default_cmd> is not set in the configuration file.
=item reset
=head1 CONFIGURATION FILE
B<novaboot-shell> reads configuration file from
-F<$HOME/.novaboot-shell>. It should define values for the following
-variables in the SH syntax.
+F<$HOME/.novaboot-shell>. It can define values for the following
+variables in the shell syntax.
=over 8
--uboot-addr=ramdisk=0x83100000
"
+=item default_cmd
+
+If set, this command is executed when no command is specified on the
+command line. If not set, C<console_cmd> is executed instead.
+
+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.
+
+In other words, C<ssh board@host> boots the board in the default
+configuration, whereas C<novaboot --ssh=board@host ...> boots the
+board as configured in C<...>.
=back
export WV_BASE_DIR
export NOVABOOT_SHELL_CONFIG="$WV_BASE_DIR/.novaboot-shell"
cat <<EOF > $NOVABOOT_SHELL_CONFIG
-console_cmd="while :; do sleep 0.1; date; done"
+console_cmd="echo 'Hello console'; while :; do sleep 0.1; date; done"
reset_cmd="touch reset_done"
target_config='--prefix=asdf'
EOF
+# Run server synchronously
function run_server() {
SSH_ORIGINAL_COMMAND="$*" SSH_CONNECTION="127.0.0.1 1234 127.0.0.1 22" $exec $WV_BASE_DIR/../server/novaboot-shell -c "${account:-user} ${username:-test} ${admin:+admin}"
}
+# Exec server (for use with coproc - then the server can be easily killed)
function exec_server() {
local exec
exec=exec
WVPASS sed -e '/novaboot-shell: Connected/q0' -e '3q1' <&${COPROC[0]}
kill $COPROC_PID; wait
-WVSTART "Console command is executed without any argument"
+WVSTART "Without any argument console_cmd is executed if no default_cmd is configured"
coproc exec_server
-WVPASS sed -e '/novaboot-shell: Connected/q0' -e '3q1' <&${COPROC[0]}
+WVPASS sed -e '/Hello console/q0' -e '3q1' <&${COPROC[0]}
kill $COPROC_PID; wait
+WVSTART "Without any argument default_cmd is executed if configured"
+(
+ export NOVABOOT_SHELL_CONFIG="./.novaboot-shell"
+ cat <<EOF > $NOVABOOT_SHELL_CONFIG
+default_cmd='echo "Hello default"'
+console_cmd='echo "Hello console"'
+EOF
+ WVPASS run_server | WVPASS grep -F 'Hello default'
+
+ WVPASS run_server console | WVPASS grep -F 'Hello console'
+)
+
WVSTART 'Second connection to console prints queue'
coproc console1 { exec_server console; }
WVPASS sed -e '/novaboot-shell: Connected/q0' -e '3q1' <&${console1[0]}