diff options
Diffstat (limited to 'recipes-extended/images/container-systemd-base.inc')
-rw-r--r-- | recipes-extended/images/container-systemd-base.inc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/recipes-extended/images/container-systemd-base.inc b/recipes-extended/images/container-systemd-base.inc new file mode 100644 index 00000000..0b856e83 --- /dev/null +++ b/recipes-extended/images/container-systemd-base.inc | |||
@@ -0,0 +1,72 @@ | |||
1 | SUMMARY ?= "Sample systemd system container" | ||
2 | DESCRIPTION ?= "A small systemd system container which will run \ | ||
3 | the application defined in IMAGE_INSTALL." | ||
4 | |||
5 | LICENSE ?= "MIT" | ||
6 | LIC_FILES_CHKSUM ?= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
7 | |||
8 | # Some commands of interest: | ||
9 | # % docker run -d --rm --name systemd_test --privileged \ | ||
10 | # --cap-add SYS_ADMIN --security-opt seccomp=unconfined --cgroup-parent=docker.slice \ | ||
11 | # --cgroupns private --tmpfs /tmp --tmpfs /run --tmpfs /run/lock zeddii/systemd-container-base | ||
12 | # | ||
13 | # % docker run -d --rm --name systemd_test --privileged \ | ||
14 | # --cgroup-parent=docker.slice --cgroupns private zeddii/c3-systemd-container | ||
15 | # | ||
16 | # % docker inspect systemd_test | ||
17 | # % docker inspect systemd_test | grep \"IPAddress\": | ||
18 | # % docker exec systemd_test bash -c "echo 'testuser:password' | chpasswd" | ||
19 | # % ssh testuser@172.17.0.2 | ||
20 | |||
21 | require container-base.bb | ||
22 | |||
23 | OCI_IMAGE_ENTRYPOINT = "/sbin/init" | ||
24 | |||
25 | IMAGE_INSTALL:append = " systemd" | ||
26 | IMAGE_INSTALL:append = " packagegroup-core-base-utils" | ||
27 | IMAGE_INSTALL:append = " packagegroup-core-ssh-openssh" | ||
28 | IMAGE_INSTALL:append = " busybox" | ||
29 | |||
30 | IMAGE_FEATURES ?= "" | ||
31 | |||
32 | NO_RECOMMENDATIONS = "1" | ||
33 | |||
34 | SERVICES_TO_DISABLE ?= " \ | ||
35 | systemd-udevd.service \ | ||
36 | systemd-udevd-control.socket \ | ||
37 | systemd-udevd-kernel.socket \ | ||
38 | proc-sys-fs-binfmt_misc.automount \ | ||
39 | sys-fs-fuse-connections.mount \ | ||
40 | sys-kernel-debug.mount \ | ||
41 | systemd-hwdb-update.service \ | ||
42 | serial-getty@ttyS0.service \ | ||
43 | dev-ttyS0.device \ | ||
44 | console-getty.service \ | ||
45 | serial-getty@.service \ | ||
46 | " | ||
47 | |||
48 | SERVICES_TO_ENABLE ?= "" | ||
49 | |||
50 | disable_systemd_services () { | ||
51 | SERVICES_TO_DISABLE="${SERVICES_TO_DISABLE}" | ||
52 | if [ -n "$SERVICES_TO_DISABLE" ]; then | ||
53 | echo "Disabling systemd services:" | ||
54 | for service in $SERVICES_TO_DISABLE; do | ||
55 | echo " $service" | ||
56 | systemctl --root="${IMAGE_ROOTFS}" mask $service > /dev/null >1 | ||
57 | done | ||
58 | fi | ||
59 | } | ||
60 | |||
61 | enable_systemd_services () { | ||
62 | SERVICES_TO_ENABLE="${SERVICES_TO_ENABLE}" | ||
63 | if [ -n "$SERVICES_TO_ENABLE" ]; then | ||
64 | echo "Enabling additional systemd services:" | ||
65 | for service in $SERVICES_TO_ENABLE; do | ||
66 | echo " $service" | ||
67 | systemctl --root="${IMAGE_ROOTFS}" enable $service > /dev/null >1 | ||
68 | done | ||
69 | fi | ||
70 | } | ||
71 | |||
72 | ROOTFS_POSTPROCESS_COMMAND += "disable_systemd_services; enable_systemd_services;" | ||