In my Debian development machine I set up a systemd-nspawn environment for customizing an embedded systemd.
I'm able to send command to this container from a script, in this way:
systemd-nspawn -q --bind /usr/bin/qemu-arm-static -D $MOUNTPATH /bin/bash << EOF
apt-get update
apt-get -y upgrade
EOF
Now I need to do the same but starting the container with the -b
(boot) flag. Is still possible to do that inside a script?
Right now I do the following manually:
- start systemd-nspawn with -b flag
- login
- issue the commands
- halt
With
screen
You'll have to apply a patch to your guest containers agetty, in my case, I had to use gentoo's specifications that enabled me to login as root without a password
You can then use screen's stuff functionality to write in whatever you'd like to send: