export WV_BASE_DIR
export NOVABOOT_SHELL_CONFIG="$WV_BASE_DIR/.novaboot-shell"
cat <<EOF > "$NOVABOOT_SHELL_CONFIG"
-target_console="/bin/sh -c 'while :; do sleep 0.1; date; done'"
-target_reset="touch reset"
+console_cmd="/bin/sh -c 'while :; do sleep 0.1; date; done'"
+reset_cmd="touch reset"
target_config() echo --prefix=asdf
EOF
admin=1 run_server help > log
WVPASS grep 'add-key' log
+WVSTART Only admin can run shell
+WVFAIL run_server shell
+admin=1 WVPASS run_server shell < /dev/null
+
WVSTART 'Cannot reset when somebody else is connected to console'
coproc console1 { exec_server console; }
WVPASS sed -e '/novaboot-shell: Connected/q0' -e '3q1' <&${console1[0]}
WVSTART "Setup SSH server's admin key"
WVPASS ssh-add -L > keys
WVPASS test $(wc -l < keys) -gt 0
+WVPASS mkdir -p $(dirname $AUTH)
+WVPASS chmod 700 $(dirname $AUTH)
WVPASS echo 'command="user test admin"' $(tail -n 1 keys) > $AUTH
WVSTART "Novaboot --ssh option (connect, rsync, reset)"
WVPASS rm -rf $TFTPROOT
TS=$(date --rfc-3339=ns)
WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset="echo $TS > reset.stamp"
+console_cmd=cat
+reset_cmd="echo $TS > reset.stamp"
target_config() :
EOF
date > file
WVSTART "Novaboot --ssh remote config"
WVPASS rm -rf $TFTPROOT
WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset=true
+console_cmd=cat
+reset_cmd=true
target_config() { echo --prefix=/prefix; echo --grub2; }
EOF
date > file
WVSTART "Novaboot --ssh remote config fails on non-safe options"
WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset=true
-target_config() { echo --prefix=/prefix; echo --make; }
+console_cmd=cat
+reset_cmd=true
+config() { echo --prefix=/prefix; echo --make; }
EOF
WVFAIL novaboot --ssh novaboot-test@localhost <<EOF
load file < date
WVSTART "Novaboot --ssh remote config fails on unknown arguments"
WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset=true
+console_cmd=cat
+reset_cmd=true
target_config() { echo --prefix=/prefix; echo blablabla; }
EOF
WVFAIL novaboot --ssh novaboot-test@localhost <<EOF