aboutsummaryrefslogtreecommitdiffstats
path: root/main/lxc
diff options
context:
space:
mode:
authorStuart Cardall <developer@it-offshore.co.uk>2017-11-13 01:41:04 +0000
committerJakub Jirutka <jakub@jirutka.cz>2017-11-26 01:17:35 +0100
commit41dbf71a6f4eb9a2be1bca68f0270e97bd52b77f (patch)
tree7f15ca4de4b52249efffe0d58a69efc866679fae /main/lxc
parentf55cfeb9c139bce7dcde2d1ecae902d9e7019ada (diff)
downloadaports-41dbf71a6f4eb9a2be1bca68f0270e97bd52b77f.tar.bz2
aports-41dbf71a6f4eb9a2be1bca68f0270e97bd52b77f.tar.xz
main/lxc: fix running systemd based containers under OpenRC
* systemd based containers require the /sys/fs/cgroup/systemd cgroup for lxc-console and services inside the containers to work * systemd_ctr() based on recommendations from lxc: https://github.com/lxc/lxc/issues/1704#issuecomment-330935480 Committer note: I did few minor modifications.
Diffstat (limited to 'main/lxc')
-rw-r--r--main/lxc/APKBUILD5
-rw-r--r--main/lxc/lxc.confd7
-rw-r--r--main/lxc/lxc.initd37
3 files changed, 46 insertions, 3 deletions
diff --git a/main/lxc/APKBUILD b/main/lxc/APKBUILD
index f24c99660f..7a7071da0e 100644
--- a/main/lxc/APKBUILD
+++ b/main/lxc/APKBUILD
@@ -21,6 +21,7 @@ subpackages="$pkgname-dev $pkgname-doc $pkgname-lvm::noarch lua5.2-lxc:_lua52
source="https://github.com/lxc/lxc/archive/lxc-$_pkgver.tar.gz
version.patch
lxc.initd
+ lxc.confd
lxc.conf
download-template-tmpfs.patch
@@ -63,6 +64,7 @@ package() {
make DESTDIR="$pkgdir" install
install -Dm755 "$srcdir"/lxc.initd "$pkgdir"/etc/init.d/lxc
+ install -Dm644 "$srcdir"/lxc.confd "$pkgdir"/etc/conf.d/lxc
install -d "$pkgdir"/var/lib/lxc
# XXX: workaround for https://github.com/lxc/lxc/issues/1095.
@@ -149,6 +151,7 @@ EOF
sha512sums="205d30a8914013f3d31bdcae9786a13b6728ae0d3630f51c644f06e1e96d03631630569a0ce55764ff7b8ee1d1d4d723926fdb2b916396aea212d9c3040b45ab lxc-2.1.1.tar.gz
e2ffcbf55447291a8434a4f37255c3a6a119bc4116c75d205006aa2b070bf6be28535cf6107bead14bbf64bf9fa415346ab544bd1c15e1add7d1c6380e6b2def version.patch
-bd4cb27659cd1b18d97cfb1415f6d57bdbc23fb4504c17b90a51c44f1fac2a4acb1fb731d744fb5211b90fa5988cc9f0e3c257b8b115b9f8522120973bbfe399 lxc.initd
+690c11a4501a093623adc3191054ed0da8dabd21ac6f8c57197d1b4a689e660d5f196978cfb9b5de5406990706a8998f0c0d181229b1688b852ded614ad97529 lxc.initd
+11bd08ef450086572fd09cfa40bf9168cb8aeb1e981fc881ae8484cd0a329c3bef262bb24880e7575ff5f75ee3caef0cb240fe5d7b770bf7ff54f2c430acd177 lxc.confd
5b83b0323e58bf00bd1e124c265729499cee97559b6fe18482962e3bed50d121b4c7a09f25cbce7b1e18d4234627bc4b4581ba2060e33cd022f105b4429cef01 lxc.conf
02fd192d137cbb5b6db6959275387d05653f41dad5a5e46ae9b53cacead8cef937733927284658d3f0b910de81f9364c7f0248db990efd88806cf3029264c214 download-template-tmpfs.patch"
diff --git a/main/lxc/lxc.confd b/main/lxc/lxc.confd
new file mode 100644
index 0000000000..7db541dc93
--- /dev/null
+++ b/main/lxc/lxc.confd
@@ -0,0 +1,7 @@
+# Configuration for /etc/init.d/lxc[.*]
+
+# Enable cgroup for systemd-based containers.
+#systemd_container=no
+
+# autostart groups (comma separated)
+#lxc_group="onboot"
diff --git a/main/lxc/lxc.initd b/main/lxc/lxc.initd
index 7d39817944..26ddaed5f0 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