]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
server: Refactor console setup to a separate function
authorMichal Sojka <michal.sojka@cvut.cz>
Mon, 25 Jan 2021 00:12:08 +0000 (01:12 +0100)
committerMichal Sojka <michal.sojka@cvut.cz>
Tue, 26 Jan 2021 08:40:13 +0000 (09:40 +0100)
Also drop exec before the command, because it only causes troubles.
Thanks to dropping exec, we had to change the testsuite, because
without exec it starts a new process, which is not killed by "kill
$COPROC_PID" and since it holds a lock (via flock), we could not run
the following tests.

This change will be useful in next commits.

server/novaboot-shell
tests/server.wv

index c8d0043e9021a089ed99eedf585389d9e0539a6a..6e647a7e78eae85ccf3bc9433686265a0e2f862d 100755 (executable)
@@ -104,17 +104,21 @@ power() {
     fi
 }
 
+run_console() {
+    trap "rm -f $RUN_DIR/ppid" EXIT
+    echo $NOVABOOT_PPID > $RUN_DIR/ppid
+    echo 'novaboot-shell: Connected'
+    # TODO: $reset_begin_cmd
+    [ -n "${on_cmd}" ] && power on
+    eval "$1"
+}
+
 # run_subcommand should be called only after permission checks and/or locking
 run_subcommand() {
     read_config
     case "$*" in
        "console")
-           trap "rm -f $RUN_DIR/ppid" EXIT
-           echo $NOVABOOT_PPID > $RUN_DIR/ppid
-           echo 'novaboot-shell: Connected'
-           # TODO: $reset_begin_cmd
-           [ -n "${on_cmd}" ] && power on
-           eval exec "${console_cmd:?}";;
+           run_console "${console_cmd:?}";;
        "reset")
            eval exec "${reset_cmd:?}";;
        "rsync --server "*" . .")
index 942425376ed5fd1ffa0dc2b3e2fde75d89fbd552..9f69633b77c0d17c4a6a8d945d6fa1eb98aa3671 100755 (executable)
@@ -7,7 +7,7 @@ NBT_HOME=$(getent passwd novaboot-test|cut -d: -f6)
 export WV_BASE_DIR
 export NOVABOOT_SHELL_CONFIG="$WV_BASE_DIR/.novaboot-shell"
 cat <<EOF > $NOVABOOT_SHELL_CONFIG
-console_cmd="/bin/sh -c 'while :; do sleep 0.1; date; done'"
+console_cmd="while :; do sleep 0.1; date; done"
 reset_cmd="touch reset_done"
 target_config='--prefix=asdf'
 EOF