Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ jobs:
sudo apt update
case ${{ matrix.arch }} in
aarch64)
sudo apt install -y --no-install-recommends netcat-traditional qemu-system-aarch64 qemu-efi-aarch64 ipxe-qemu
sudo apt install -y --no-install-recommends ncat qemu-system-aarch64 qemu-efi-aarch64 ipxe-qemu
;;
x86 | amd64)
sudo apt install -y --no-install-recommends netcat-traditional qemu-system-x86
sudo apt install -y --no-install-recommends ncat qemu-system-x86
;;
armv6)
sudo apt install -y --no-install-recommends netcat-traditional qemu-system-arm
sudo apt install -y --no-install-recommends ncat qemu-system-arm
;;
*)
echo "Don't know what to install"
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
if [ "${{ matrix.os }}-${{ matrix.arch }}" == "raspios-armv6" ]; then
# qemu doesn't really support armv6 shutting down (if that's a thing anyway???)
# Instead linux kernel panics because init is exiting. Let's wait for that.
vm/wait_for_string.sh 'not syncing: Attempted to kill init' nc.traditional localhost 2222
vm/wait_for_string.sh 'not syncing: Attempted to kill init' ncat --no-shutdown localhost 2222
kill -INT $(cat vm/${{ matrix.os }}-${{ matrix.arch }}/pid.txt)
else
echo "Waiting for VM to shut down..."
Expand Down
12 changes: 7 additions & 5 deletions vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,20 @@ Here are some guidelines for working on the scripts:
- Use `set -e -o pipefail`. If this gets in your way, use `|| true` only in the
places that need it. This way failures are not silenced except where you
expect to get failures.
- Use `nc.traditional` instead of `nc`. There are several different versions of
netcat, and they are similar but incompatible in subtle ways. For example,
`echo | nc ...` doesn't work as expected with `ncat`, because `ncat` closes
the connection when it gets EOF on stdin.
- Use `ncat` instead of `nc`. The `nc` command can be any of several different
netcat implementations: it may be same as `ncat`, or something else. The
different implementations are similar but incompatible in subtle ways. For
example, when `nc` gets EOF on stdin, some `nc` implementations (like `ncat`)
close the connection while others keep it open. I chose to use `ncat` because
it is available with the same name in most linux distros.
- Use the [`wait_for_string.sh`](./wait_for_string.sh) script instead of the
`expect` program, for two reasons:
- Jou developers already need to know at least 4 programming languages, and
I don't really want to add Tcl to the mix.
- `expect` would be an unnecessary dependency.

Dependencies (in addition to what you need for Jou anyway):
- All architectures and operating systems: `sudo apt install wget openssh-client netcat-traditional`
- All architectures and operating systems: `sudo apt install wget openssh-client ncat`
- x86: `sudo apt install qemu-system-x86`
- aarch64: `sudo apt install qemu-system-aarch64 qemu-efi-aarch64 ipxe-qemu`
- armv6: `sudo apt install qemu-system-arm`
Expand Down
6 changes: 3 additions & 3 deletions vm/alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ if ! [ -f disk.img ]; then
qemu_pid=$!

echo "Waiting for temporary VM to boot so we can install alpine..."
until echo | ../wait_for_string.sh 'localhost login:' nc.traditional localhost 4444; do
until echo | ../wait_for_string.sh 'localhost login:' ncat --no-shutdown localhost 4444; do
sleep 1
kill -0 $qemu_pid # Stop if qemu dies
done

echo "Logging in to temporary VM..."
echo root | ../wait_for_string.sh 'localhost:~#' nc.traditional localhost 4444
echo root | ../wait_for_string.sh 'localhost:~#' ncat --no-shutdown localhost 4444

echo "Installing alpine..."
echo "
Expand All @@ -82,7 +82,7 @@ setup-alpine -f answerfile -e
y
sync
poweroff
" | nc.traditional localhost 4444
" | ncat --no-shutdown localhost 4444
wait # Make sure qemu has died before we proceed further
trap - EXIT # Don't delete disk.img when we exit
fi
Expand Down
4 changes: 2 additions & 2 deletions vm/netbsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if ! timeout 5 ../ssh.sh echo hello; then
# We consider the VM started when it shows login prompt on serial port.
# At that point it has also started ssh.
echo "Waiting for VM to boot..."
until echo | ../wait_for_string.sh 'login:' nc.traditional localhost 4444; do
until echo | ../wait_for_string.sh 'login:' ncat --no-shutdown localhost 4444; do
sleep 1
kill -0 $qemu_pid # Stop if qemu dies
done
Expand All @@ -105,7 +105,7 @@ mkdir .ssh
chmod 700 .ssh
echo '$(../keygen.sh)' > .ssh/authorized_keys
echo ALL'DONE'NOW
exit" | ../wait_for_string.sh 'ALLDONENOW' nc.traditional localhost 4444
exit" | ../wait_for_string.sh 'ALLDONENOW' ncat --no-shutdown localhost 4444
echo "Now ssh setup is done, let's check one last time..."
../ssh.sh echo hello # Check that it works
fi
Expand Down
2 changes: 1 addition & 1 deletion vm/raspios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ else
disown

echo "Waiting for VM to boot..."
until echo | ../wait_for_string.sh 'raspberrypi login:' nc.traditional localhost 4444; do
until echo | ../wait_for_string.sh 'raspberrypi login:' ncat --no-shutdown localhost 4444; do
sleep 1
kill -0 $qemu_pid # Stop if qemu dies
done
Expand Down
2 changes: 1 addition & 1 deletion vm/wait_for_string.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# For example, this logs in as root to serial console on localhost:4444, and
# waits until the shell prompt appears:
#
# $ echo root | ./wait_for_string.sh "root@localhost:~#" nc.traditional localhost 4444
# $ echo root | ./wait_for_string.sh "root@localhost:~#" ncat --no-shutdown localhost 4444
#
# Here is another example, which is more useful for developing this script. It
# tells Python to print "blah" and "foobar", with 1 second delays before and
Expand Down