1 |
commit: c709e6077c6eda3f4f7e7222298213413254ee0f |
2 |
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Apr 28 20:07:21 2015 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri May 1 14:04:07 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c709e607 |
7 |
|
8 |
Add support for systemd-nspawn containers |
9 |
|
10 |
This adds support for running OpenRC in a container created by |
11 |
the systemd-nspawn utility. |
12 |
|
13 |
This fixes #52. |
14 |
|
15 |
X-Gentoo-Bug: 548058 |
16 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548058 |
17 |
|
18 |
etc/rc.conf.Linux | 17 +++++++++-------- |
19 |
sh/openrc-run.sh.in | 5 ++++- |
20 |
src/librc/librc.c | 2 ++ |
21 |
src/librc/rc.h.in | 1 + |
22 |
4 files changed, 16 insertions(+), 9 deletions(-) |
23 |
|
24 |
diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux |
25 |
index 79bd971..a8ad58b 100644 |
26 |
--- a/etc/rc.conf.Linux |
27 |
+++ b/etc/rc.conf.Linux |
28 |
@@ -2,14 +2,15 @@ |
29 |
# LINUX SPECIFIC OPTIONS |
30 |
|
31 |
# This is the subsystem type. Valid options on Linux: |
32 |
-# "" - nothing special |
33 |
-# "lxc" - Linux Containers |
34 |
-# "openvz" - Linux OpenVZ |
35 |
-# "prefix" - Prefix |
36 |
-# "uml" - Usermode Linux |
37 |
-# "vserver" - Linux vserver |
38 |
-# "xen0" - Xen0 Domain |
39 |
-# "xenU" - XenU Domain |
40 |
+# "" - nothing special |
41 |
+# "lxc" - Linux Containers |
42 |
+# "openvz" - Linux OpenVZ |
43 |
+# "prefix" - Prefix |
44 |
+# "uml" - Usermode Linux |
45 |
+# "vserver" - Linux vserver |
46 |
+# "systemd-nspawn" - Container created by the systemd-nspawn utility |
47 |
+# "xen0" - Xen0 Domain |
48 |
+# "xenU" - XenU Domain |
49 |
# If this is commented out, automatic detection will be used. |
50 |
# |
51 |
# This should be set to the value representing the environment this file is |
52 |
|
53 |
diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in |
54 |
index a6d2c0b..e279f11 100644 |
55 |
--- a/sh/openrc-run.sh.in |
56 |
+++ b/sh/openrc-run.sh.in |
57 |
@@ -34,7 +34,10 @@ sourcex() |
58 |
|
59 |
sourcex "@LIBEXECDIR@/sh/functions.sh" |
60 |
sourcex "@LIBEXECDIR@/sh/rc-functions.sh" |
61 |
-[ "$RC_SYS" != "PREFIX" ] && sourcex -e "@LIBEXECDIR@/sh/rc-cgroup.sh" |
62 |
+case $RC_SYS in |
63 |
+ PREFIX|SYSTEMD-NSPAWN) ;; |
64 |
+ *) sourcex -e "@LIBEXECDIR@/sh/rc-cgroup.sh";; |
65 |
+esac |
66 |
|
67 |
# Support LiveCD foo |
68 |
if sourcex -e "/sbin/livecd-functions.sh"; then |
69 |
|
70 |
diff --git a/src/librc/librc.c b/src/librc/librc.c |
71 |
index ca51aa6..03448e7 100644 |
72 |
--- a/src/librc/librc.c |
73 |
+++ b/src/librc/librc.c |
74 |
@@ -294,6 +294,8 @@ rc_sys_v1(void) |
75 |
return RC_SYS_OPENVZ; /* old test */ |
76 |
else if (file_regex("/proc/1/environ", "container=lxc")) |
77 |
return RC_SYS_LXC; |
78 |
+ else if (file_regex("/proc/1/environ", "container=systemd-nspawn")) |
79 |
+ return RC_SYS_SYSTEMD_NSPAWN; |
80 |
#endif |
81 |
|
82 |
return NULL; |
83 |
|
84 |
diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in |
85 |
index 58d8eb5..13e1b5b 100644 |
86 |
--- a/src/librc/rc.h.in |
87 |
+++ b/src/librc/rc.h.in |
88 |
@@ -332,6 +332,7 @@ bool rc_service_daemons_crashed(const char *); |
89 |
#define RC_SYS_OPENVZ "OPENVZ" |
90 |
#define RC_SYS_LXC "LXC" |
91 |
#define RC_SYS_PREFIX "PREFIX" |
92 |
+#define RC_SYS_SYSTEMD_NSPAWN "SYSTEMD-NSPAWN" |
93 |
#define RC_SYS_UML "UML" |
94 |
#define RC_SYS_VSERVER "VSERVER" |
95 |
#define RC_SYS_XEN0 "XEN0" |