Add support for systemd-nspawn containers
This adds support for running OpenRC in a container created by the systemd-nspawn utility. This fixes #52. X-Gentoo-Bug: 548058 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548058
This commit is contained in:
		| @@ -2,14 +2,15 @@ | |||||||
| # LINUX SPECIFIC OPTIONS | # LINUX SPECIFIC OPTIONS | ||||||
|  |  | ||||||
| # This is the subsystem type. Valid options on Linux: | # This is the subsystem type. Valid options on Linux: | ||||||
| # ""        - nothing special | # ""               - nothing special | ||||||
| # "lxc"     - Linux Containers | # "lxc"            - Linux Containers | ||||||
| # "openvz"  - Linux OpenVZ | # "openvz"         - Linux OpenVZ | ||||||
| # "prefix"  - Prefix | # "prefix"         - Prefix | ||||||
| # "uml"     - Usermode Linux | # "uml"            - Usermode Linux | ||||||
| # "vserver" - Linux vserver | # "vserver"        - Linux vserver | ||||||
| # "xen0"    - Xen0 Domain | # "systemd-nspawn" - Container created by the systemd-nspawn utility | ||||||
| # "xenU"    - XenU Domain | # "xen0"           - Xen0 Domain | ||||||
|  | # "xenU"           - XenU Domain | ||||||
| # If this is commented out, automatic detection will be used. | # If this is commented out, automatic detection will be used. | ||||||
| # | # | ||||||
| # This should be set to the value representing the environment this file is | # This should be set to the value representing the environment this file is | ||||||
|   | |||||||
| @@ -34,7 +34,10 @@ sourcex() | |||||||
|  |  | ||||||
| sourcex "@LIBEXECDIR@/sh/functions.sh" | sourcex "@LIBEXECDIR@/sh/functions.sh" | ||||||
| sourcex "@LIBEXECDIR@/sh/rc-functions.sh" | sourcex "@LIBEXECDIR@/sh/rc-functions.sh" | ||||||
| [ "$RC_SYS" != "PREFIX" ] && sourcex -e "@LIBEXECDIR@/sh/rc-cgroup.sh" | case $RC_SYS in | ||||||
|  | 	PREFIX|SYSTEMD-NSPAWN) ;; | ||||||
|  | 	*) sourcex -e "@LIBEXECDIR@/sh/rc-cgroup.sh";; | ||||||
|  | esac | ||||||
|  |  | ||||||
| # Support LiveCD foo | # Support LiveCD foo | ||||||
| if sourcex -e "/sbin/livecd-functions.sh"; then | if sourcex -e "/sbin/livecd-functions.sh"; then | ||||||
|   | |||||||
| @@ -294,6 +294,8 @@ rc_sys_v1(void) | |||||||
| 		return RC_SYS_OPENVZ; /* old test */ | 		return RC_SYS_OPENVZ; /* old test */ | ||||||
| 	else if (file_regex("/proc/1/environ", "container=lxc")) | 	else if (file_regex("/proc/1/environ", "container=lxc")) | ||||||
| 		return RC_SYS_LXC; | 		return RC_SYS_LXC; | ||||||
|  | 	else if (file_regex("/proc/1/environ", "container=systemd-nspawn")) | ||||||
|  | 		return RC_SYS_SYSTEMD_NSPAWN; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	return NULL; | 	return NULL; | ||||||
|   | |||||||
| @@ -332,6 +332,7 @@ bool rc_service_daemons_crashed(const char *); | |||||||
| #define RC_SYS_OPENVZ  "OPENVZ" | #define RC_SYS_OPENVZ  "OPENVZ" | ||||||
| #define RC_SYS_LXC     "LXC" | #define RC_SYS_LXC     "LXC" | ||||||
| #define RC_SYS_PREFIX  "PREFIX" | #define RC_SYS_PREFIX  "PREFIX" | ||||||
|  | #define RC_SYS_SYSTEMD_NSPAWN "SYSTEMD-NSPAWN" | ||||||
| #define RC_SYS_UML     "UML" | #define RC_SYS_UML     "UML" | ||||||
| #define RC_SYS_VSERVER "VSERVER" | #define RC_SYS_VSERVER "VSERVER" | ||||||
| #define RC_SYS_XEN0    "XEN0" | #define RC_SYS_XEN0    "XEN0" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user