Issue
I try to automate the configuration of raspios through bash script. My configurations are on network level and for that I need to install a package named vlan, so my try ist to use systemd-nspwan on mounted image.
My Problem is, when I start the container, a new shell is opened.
I need to install the package and after that close the container / shell to return to the root.
systemd-nspawn -D /mnt
if dpkg -l | grep vlan; then
exit 1
else
apt install vlan
fi
How can I exit the subshell so I can get back to root?
Solution
By reading the mans page of systemd-nspawn I found out that you can pass the command without opening an interactive shell by simply adding your wished command as an parameter of systemd-nspwan.
systemd-nspawn <wished command>
Answered By - DirkBurton Answer Checked By - Senaida (WPSolving Volunteer)