summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gentoo.org>2010-08-01 21:13:46 +0000
committerDiego Elio Pettenò <flameeyes@gentoo.org>2010-08-01 21:13:46 +0000
commit94fb3619948d233e6499c90e5e2b07b7f86a987f (patch)
tree47447705c4e8e50111fb398a959be225bcf2e3ae /app-emulation
parentPatchset bump to fix bug #327191 for SH. (diff)
downloadhistorical-94fb3619948d233e6499c90e5e2b07b7f86a987f.tar.gz
historical-94fb3619948d233e6499c90e5e2b07b7f86a987f.tar.bz2
historical-94fb3619948d233e6499c90e5e2b07b7f86a987f.zip
New init script, with more thorough verification of the config, support for mounting the cgroup pseudo-fs, proper network dependencies, improved start-up (verifies that the container actually started up) and stop (won't waste time if the container was externally stopped).
Package-Manager: portage-2.2_rc67/cvs/Linux x86_64
Diffstat (limited to 'app-emulation')
-rw-r--r--app-emulation/lxc/ChangeLog11
-rw-r--r--app-emulation/lxc/Manifest12
-rw-r--r--app-emulation/lxc/files/lxc.initd69
-rw-r--r--app-emulation/lxc/lxc-0.7.2-r1.ebuild (renamed from app-emulation/lxc/lxc-0.7.2.ebuild)3
4 files changed, 76 insertions, 19 deletions
diff --git a/app-emulation/lxc/ChangeLog b/app-emulation/lxc/ChangeLog
index 1f7c68870a8d..f774d4f261d2 100644
--- a/app-emulation/lxc/ChangeLog
+++ b/app-emulation/lxc/ChangeLog
@@ -1,6 +1,15 @@
# ChangeLog for app-emulation/lxc
# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/ChangeLog,v 1.14 2010/08/01 03:17:50 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/ChangeLog,v 1.15 2010/08/01 21:13:45 flameeyes Exp $
+
+*lxc-0.7.2-r1 (01 Aug 2010)
+
+ 01 Aug 2010; Diego E. Pettenò <flameeyes@gentoo.org> -lxc-0.7.2.ebuild,
+ +lxc-0.7.2-r1.ebuild, files/lxc.initd:
+ New init script, with more thorough verification of the config, support
+ for mounting the cgroup pseudo-fs, proper network dependencies, improved
+ start-up (verifies that the container actually started up) and stop (won't
+ waste time if the container was externally stopped).
*lxc-0.7.2 (01 Aug 2010)
diff --git a/app-emulation/lxc/Manifest b/app-emulation/lxc/Manifest
index 0ddefd187f93..b1cafeb349ae 100644
--- a/app-emulation/lxc/Manifest
+++ b/app-emulation/lxc/Manifest
@@ -1,17 +1,17 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-AUX lxc.initd 1674 RMD160 783577ab296b6951527963074099ffdd69154742 SHA1 234cc4ad663f343305ceee15ed83e2aa3c8c80cc SHA256 2dd5b7ed967ebe29240d61e71f47911395207d896d42f9e6fb5e9f6e9d5c0b7e
+AUX lxc.initd 3198 RMD160 040fe0799306a781201500b5cd6b4fd1b23a2b39 SHA1 159d86282ba7be1541b7e1899a935cf4688ef0db SHA256 14a918e913173b1c9d3782e9b3df2471bb9d715df1d9d3f1e030f42da62f6d69
DIST lxc-0.7.1.tar.gz 264376 RMD160 a57c978b50f2f6df15d526d4d5d25c8cd438e9cf SHA1 06dab217dd67b10acc57e2566f80b0673f0261f2 SHA256 da7a0b4f684a0d1d9d982c8423f1143a59798a0fab6c30e0c1aae752c578a642
DIST lxc-0.7.2.tar.gz 266877 RMD160 3c4f2a751c1f4965bab75d9825e4d9d0642a4a4b SHA1 75dfc113a576fa15d46a3736ff788a168de0b258 SHA256 0660edbc08d74275968cb18c8e634aafd6f1ad395419e037d7018f2b1d669b1a
EBUILD lxc-0.7.1.ebuild 2155 RMD160 4dd61fc556387bcc1d1017bb8a6a18b4f3199437 SHA1 aea867f6771006d9cbed10e1949046d654a4007c SHA256 a4d7a27f6902f826704738ccb8dac2139b9c64a92735fcdc3868229493764bec
-EBUILD lxc-0.7.2.ebuild 3048 RMD160 b549c08c106eb9ca7959c350857f2c454eb65a8f SHA1 48240a26cc5dfe1ab2a6f167a055a5471d50e000 SHA256 22268e3172e0580753727b0e9a946d115208c1c5c44ca41a6ee4e1bf11cf0501
-MISC ChangeLog 3441 RMD160 fd66baab077a8b20c435c2bcf316c050fd065c67 SHA1 4a3549e0694757b518f5280a176def9b503cc398 SHA256 12df80240a389fe856a62b3089f336c6ae4e2cfd032d78ed21fd171840c54a64
+EBUILD lxc-0.7.2-r1.ebuild 3073 RMD160 b04383df106bf68dfc65967c595ae0ac2c25ed02 SHA1 0b5663325909d39b8682603293b2dc1db893c169 SHA256 0118908c15e225b06efca3648d6734a384faa3443c84709e2ae4861615c67402
+MISC ChangeLog 3868 RMD160 a0ea9ef2c2e3abf7ad405d4df46a6287c04fa483 SHA1 016447864b24f59aaae041fa597803ccacc75bf1 SHA256 cb4bb0f8c19b2a35efb13063adf02d7b2e8ea83f5f4844803b306c7f503181f5
MISC metadata.xml 653 RMD160 d6139a7ce3a5dab18f33c7f111f2e7827c290723 SHA1 47ba631625b4f2b20e491a964e65c78dd236f6f2 SHA256 35f64761067f47ff7abd0e3f3cb57f4bab888a2546bf3267d59987505101a190
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
-iEYEARECAAYFAkxU51EACgkQAiZjviIA2XiqDACgqzxSTts+889cEzuQKUQvgu2P
-KscAoPJ05B20jk8DiqnGH5ca7Lt8aIC6
-=XkpP
+iEYEARECAAYFAkxV43UACgkQAiZjviIA2XiDtgCgyUKhh/EcBvP7HEupo85Qre9h
+VcYAoN4Q4UxtLG6k9RKtLtbmeRr31AOa
+=kb3A
-----END PGP SIGNATURE-----
diff --git a/app-emulation/lxc/files/lxc.initd b/app-emulation/lxc/files/lxc.initd
index 99706980cb2d..78acc1400a3e 100644
--- a/app-emulation/lxc/files/lxc.initd
+++ b/app-emulation/lxc/files/lxc.initd
@@ -1,13 +1,17 @@
#!/sbin/runscript
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 2010-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.1 2010/08/01 03:17:51 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.2 2010/08/01 21:13:46 flameeyes Exp $
CONTAINER=${SVCNAME#*.}
CONFIGFILE=${CONFIGFILE:-/etc/lxc/${CONTAINER}.conf}
-depend() {
- need net.lo localmount
+lxc_get_var() {
+ awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE}
+}
+
+cgroup_get_mount() {
+ mount | awk '$5 == "cgroup" { print $3; exit }'
}
checkconfig() {
@@ -16,37 +20,81 @@ checkconfig() {
eerror " ln -s lxc /etc/init.d/lxc.container"
return 1
fi
+
+ utsname=$(lxc_get_var lxc.utsname)
+ if [ ${CONTAINER} != ${utsname} ]; then
+ eerror "You should use the same name for the service and the"
+ eerror "container. Right now the container is called ${utsname}"
+ return 1
+ fi
}
-rootpath() {
- sed -n -e 's:^[ \t]*lxc.rootfs[ \t]*=[ \t]*\(.*\)$:\1:p' ${CONFIGFILE}
+depend() {
+ # be quiet, since we have to run depend() also for the
+ # non-muxed init script, unfortunately.
+ checkconfig 2>/dev/null || return 0
+
+ config ${CONFIGFILE}
+ need localmount
+
+ # find out which network interface the container is linked to,
+ # and then require that to be enabled, so that the
+ # dependencies are correct.
+ netif=$(lxc_get_var lxc.network.link)
+ [ -n "${netif}" ] && need net.${netif}
}
start() {
checkconfig || return 1
+ # make sure that cgroup is mounted if it isn't already, this
+ # ensures that we can actually proceed!
+ cgroupmount=$(cgroup_get_mount)
+ if [ -z ${cgroupmount} ]; then
+ mkdir -p /cgroup
+
+ if ! mount -t cgroup cgroup /cgroup; then
+ eerror "Unable to mount cgroup pseudo-filesystem on /cgroup"
+ return 1
+ fi
+
+ cgroupmount=/cgroup
+ fi
+
rm /var/log/lxc/${CONTAINER}.log
+ rootpath=$(lxc_get_var lxc.rootfs)
+
# Check the format of our init and the chroot's init, to see if we
# have to use linux32 or linux64…
- case $(scanelf -BF '%M#f' /sbin/init $(rootpath)/sbin/init | tr '\n' ':') in
+ case $(scanelf -BF '%M#f' /sbin/init ${rootpath}/sbin/init | tr '\n' ':') in
ELFCLASS64:ELFCLASS64:) setarch=;;
ELFCLASS32:ELFCLASS32:) setarch=;;
ELFCLASS32:ELFCLASS64:) setarch=linux64;;
ELFCLASS64:ELFCLASS32:) setarch=linux32;;
esac
- mkdir -p /var/log/lxc
-
ebegin "Starting ${CONTAINER}"
${setarch} lxc-start -n ${CONTAINER} -f ${CONFIGFILE} -d -o /var/log/lxc/${CONTAINER}.log
+ sleep 0.5
+
+ # lxc-start -d will _always_ report a correct startup, even if it
+ # failed, so rather than trust that, check that the cgroup exists.
+ [ -d ${cgroupmount}/${CONTAINER} ]
eend $?
}
stop() {
checkconfig || return 1
- local init_pid=$(head -n1 /cgroup/${CONTAINER}/tasks)
+ cgroupmount=$(cgroup_get_mount)
+
+ if ! [ -d ${cgroupmount}/${CONTAINER} ]; then
+ ewarn "${CONTAINER} doesn't seem to be started."
+ return 0
+ fi
+
+ init_pid=$(head -n1 ${cgroupmount}/${CONTAINER}/tasks)
ebegin "Shutting down system in ${CONTAINER}"
kill -INT ${init_pid}
@@ -64,4 +112,3 @@ stop() {
lxc-stop -n ${CONTAINER}
eend $?
}
-
diff --git a/app-emulation/lxc/lxc-0.7.2.ebuild b/app-emulation/lxc/lxc-0.7.2-r1.ebuild
index ccf6066c7099..c7b0648486e5 100644
--- a/app-emulation/lxc/lxc-0.7.2.ebuild
+++ b/app-emulation/lxc/lxc-0.7.2-r1.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/lxc-0.7.2.ebuild,v 1.1 2010/08/01 03:17:50 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/lxc-0.7.2-r1.ebuild,v 1.1 2010/08/01 21:13:45 flameeyes Exp $
EAPI="2"
@@ -90,6 +90,7 @@ src_install() {
# Gentoo-specific additions!
newinitd "${FILESDIR}/${PN}.initd" ${PN}
+ keepdir /var/log/lxc
}
pkg_postinst() {