-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
create-sosroot.sh
executable file
·56 lines (41 loc) · 1.34 KB
/
create-sosroot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
#
# SPDX-License-Identifier: MPL-2.0
#
# Copyright: © 2023 Serpent OS Developers
#
# create-sosroot.sh:
# script for conveniently creating a clean /var/lib/machines/sosroot/
# directory suitable for use as the root in serpent os systemd-nspawn
# container or linux-kvm kernel driven qemu-kvm virtual machine.
source ./basic-setup.sh
showHelp() {
cat <<EOF
----
You can now start a systemd-nspawn container with:
sudo systemd-nspawn --bind=${BOULDERCACHE}/ -D ${SOSROOT}/ -b
OR
sudo ./boot-systemd-nspawn-container.sh (rewritten on each ./create-sosroot.sh run)
Do a 'systemctl poweroff' inside the container to shut it down.
The container can also be shut down with:
sudo machinectl stop sosroot
in a shell outside the container.
If you want to be able to use your sosroot/ with virt-manager,
you can set the DESTDIR variable when calling ${0} like so:
DESTDIR="/var/lib/machines/sosroot" create-sosroot.sh
EOF
}
# Make it more convenient to boot into the created sosroot/ later on
createBootScript () {
cat <<EOF > boot-systemd-nspawn-container.sh
#!/usr/bin/env bash
#
exec sudo systemd-nspawn --bind=${BOULDERCACHE}/ -D ${SOSROOT}/ -b
EOF
}
checkPrereqs
basicSetup
showHelp
# Make it simple to boot into the created sosroot at a later point
createBootScript && chmod a+x boot-systemd-nspawn-container.sh
cleanEnv