aboutsummaryrefslogtreecommitdiffstats
path: root/main/lxc/lxc.initd
diff options
context:
space:
mode:
Diffstat (limited to 'main/lxc/lxc.initd')
-rw-r--r--main/lxc/lxc.initd37
1 files changed, 35 insertions, 2 deletions
diff --git a/main/lxc/lxc.initd b/main/lxc/lxc.initd
index 7d39817944d..26ddaed5f06 100644
--- a/main/lxc/lxc.initd
+++ b/main/lxc/lxc.initd
@@ -3,10 +3,17 @@
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd.2,v 1.5 2012/07/21 05:07:15 flameeyes Exp $
+extra_started_commands="reboot"
+
+description="Linux Containers (LXC)"
+description_reboot="Reboot containers"
+
CONTAINER=${SVCNAME#*.}
+: ${lxc_group:=$LXC_GROUP}
+: ${systemd_container:=no}
+
command="/usr/bin/lxc-start"
pidfile="/var/run/lxc/$CONTAINER.pid"
-extra_started_commands="reboot"
depend() {
need localmount sysfs
@@ -51,15 +58,39 @@ checkconfig() {
fi
}
+systemd_ctr() {
+ local cmd="$1"
+ # Required for lxc-console and services inside systemd containers.
+ local cgroup=/sys/fs/cgroup/systemd
+ local mnt_opts='rw,nosuid,nodev,noexec,relatime,none,name=systemd'
+
+ case "$cmd" in
+ mount)
+ checkpath -d $cgroup
+ if ! mount | grep $cgroup >/dev/null; then
+ mount -t cgroup -o $mnt_opts cgroup $cgroup
+ fi
+ ;;
+ unmount)
+ if mount | grep $cgroup >/dev/null; then
+ umount $cgroup
+ fi
+ ;;
+ esac
+}
+
_autostart() {
ebegin "$1 LXC containers"
shift
- lxc-autostart --group "${LXC_GROUP:-onboot,}" "$@"
+ lxc-autostart --group "$lxc_group" "$@"
eend $?
}
start() {
checkconfig || return 1
+ if yesno "$systemd_container"; then
+ systemd_ctr mount
+ fi
if [ -z "$CONTAINER" ]; then
_autostart "Starting"
return
@@ -97,6 +128,8 @@ start() {
stop() {
checkconfig || return 1
+ systemd_ctr unmount
+
if [ -z "$CONTAINER" ]; then
_autostart "Stopping" --shutdown --timeout ${LXC_TIMEOUT:-30}
return