summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gentoo.org>2011-04-24 15:24:45 +0000
committerDiego Elio Pettenò <flameeyes@gentoo.org>2011-04-24 15:24:45 +0000
commit93b09c65047067cf127cfaa842916ec3e37d359a (patch)
treecab3d1384bd7e1cb2c8587bd56c4dd09f29ce048 /app-emulation/lxc
parentMarked ~x86-solaris, bug #296509 (diff)
downloadgentoo-2-93b09c65047067cf127cfaa842916ec3e37d359a.tar.gz
gentoo-2-93b09c65047067cf127cfaa842916ec3e37d359a.tar.bz2
gentoo-2-93b09c65047067cf127cfaa842916ec3e37d359a.zip
Revision bump to improve the init script so that it searches the new location of configuration files created by lxc-create (closes bug #364611).
(Portage version: 2.2.0_alpha30/cvs/Linux x86_64)
Diffstat (limited to 'app-emulation/lxc')
-rw-r--r--app-emulation/lxc/ChangeLog9
-rw-r--r--app-emulation/lxc/files/lxc.initd170
-rw-r--r--app-emulation/lxc/lxc-0.7.4.1-r1.ebuild (renamed from app-emulation/lxc/lxc-0.7.4.1.ebuild)2
3 files changed, 103 insertions, 78 deletions
diff --git a/app-emulation/lxc/ChangeLog b/app-emulation/lxc/ChangeLog
index 3f3d55f9ccf8..50dfe2f43d92 100644
--- a/app-emulation/lxc/ChangeLog
+++ b/app-emulation/lxc/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for app-emulation/lxc
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/ChangeLog,v 1.21 2011/03/30 12:09:06 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/ChangeLog,v 1.22 2011/04/24 15:24:44 flameeyes Exp $
+
+*lxc-0.7.4.1-r1 (24 Apr 2011)
+
+ 24 Apr 2011; Diego E. Pettenò <flameeyes@gentoo.org> -lxc-0.7.4.1.ebuild,
+ +lxc-0.7.4.1-r1.ebuild, files/lxc.initd:
+ Revision bump to improve the init script so that it searches the new location
+ of configuration files created by lxc-create (closes bug #364611).
*lxc-0.7.4.1 (30 Mar 2011)
diff --git a/app-emulation/lxc/files/lxc.initd b/app-emulation/lxc/files/lxc.initd
index 86bae5f75762..4388fb2304bf 100644
--- a/app-emulation/lxc/files/lxc.initd
+++ b/app-emulation/lxc/files/lxc.initd
@@ -1,32 +1,50 @@
#!/sbin/runscript
# Copyright 1999-2011 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.3 2011/02/26 18:02:51 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.4 2011/04/24 15:24:44 flameeyes Exp $
CONTAINER=${SVCNAME#*.}
CONFIGFILE=${CONFIGFILE:-/etc/lxc/${CONTAINER}.conf}
+lxc_get_configfile() {
+ if [ -n "${CONFIGFILE}" ]; then
+ echo "${CONFIGFILE}"
+ elif [ -f "/etc/lxc/${CONTAINER}.conf" ]; then
+ echo "/etc/lxc/${CONTAINER}.conf"
+ elif [ -f "/etc/lxc/${CONTAINER}/config" ]; then
+ echo "/etc/lxc/${CONTAINER}/config"
+ else
+ eerror "Unable to find a suitable configuration file."
+ eerror "If you set up the contianer in a non-standard"
+ eerror "location, please set the CONFIGFILE variable."
+ return 1
+ fi
+}
+
lxc_get_var() {
- awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE}
+ awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' $(lxc_get_configfile)
}
cgroup_get_mount() {
- mount | awk '$5 == "cgroup" { print $3; exit }'
+ mount | awk '$5 == "cgroup" { print $3; exit }'
}
checkconfig() {
- if [ ${CONTAINER} = ${SVCNAME} ]; then
- eerror "You have to create an init script for each container:"
- 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
+ if [ ${CONTAINER} = ${SVCNAME} ]; then
+ eerror "You have to create an init script for each container:"
+ eerror " ln -s lxc /etc/init.d/lxc.container"
+ return 1
+ fi
+
+ # no need to output anything, the function takes care of that.
+ [ -z "$(lxc_get_configfile)" ] && return 1
+
+ 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
}
depend() {
@@ -34,81 +52,81 @@ depend() {
# non-muxed init script, unfortunately.
checkconfig 2>/dev/null || return 0
- config ${CONFIGFILE}
+ config $(lxc_get_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}
+ # 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
- ELFCLASS64:ELFCLASS64:) setarch=;;
- ELFCLASS32:ELFCLASS32:) setarch=;;
- ELFCLASS32:ELFCLASS64:) setarch=linux64;;
- ELFCLASS64:ELFCLASS32:) setarch=linux32;;
- esac
-
- ebegin "Starting ${CONTAINER}"
- ${setarch} lxc-start -l WARN -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 $?
+ 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
+ ELFCLASS64:ELFCLASS64:) setarch=;;
+ ELFCLASS32:ELFCLASS32:) setarch=;;
+ ELFCLASS32:ELFCLASS64:) setarch=linux64;;
+ ELFCLASS64:ELFCLASS32:) setarch=linux32;;
+ esac
+
+ ebegin "Starting ${CONTAINER}"
+ ${setarch} lxc-start -l WARN -n ${CONTAINER} -f $(lxc_get_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
+ checkconfig || return 1
- cgroupmount=$(cgroup_get_mount)
+ cgroupmount=$(cgroup_get_mount)
- if ! [ -d ${cgroupmount}/${CONTAINER} ]; then
- ewarn "${CONTAINER} doesn't seem to be started."
- return 0
- fi
+ if ! [ -d ${cgroupmount}/${CONTAINER} ]; then
+ ewarn "${CONTAINER} doesn't seem to be started."
+ return 0
+ fi
- init_pid=$(head -n1 ${cgroupmount}/${CONTAINER}/tasks)
+ init_pid=$(head -n1 ${cgroupmount}/${CONTAINER}/tasks)
- ebegin "Shutting down system in ${CONTAINER}"
- kill -INT ${init_pid}
- eend $?
+ ebegin "Shutting down system in ${CONTAINER}"
+ kill -INT ${init_pid}
+ eend $?
- sleep 15
+ sleep 15
- missingprocs=$(pgrep -P ${init_pid})
+ missingprocs=$(pgrep -P ${init_pid})
- if [ -n "${missingprocs}" ]; then
- ewarn "Something failed to properly shut down in ${CONTAINER}"
- fi
+ if [ -n "${missingprocs}" ]; then
+ ewarn "Something failed to properly shut down in ${CONTAINER}"
+ fi
- ebegin "Stopping ${CONTAINER}"
- lxc-stop -n ${CONTAINER}
- eend $?
+ ebegin "Stopping ${CONTAINER}"
+ lxc-stop -n ${CONTAINER}
+ eend $?
}
diff --git a/app-emulation/lxc/lxc-0.7.4.1.ebuild b/app-emulation/lxc/lxc-0.7.4.1-r1.ebuild
index d47f902cd057..3ff2f65aa066 100644
--- a/app-emulation/lxc/lxc-0.7.4.1.ebuild
+++ b/app-emulation/lxc/lxc-0.7.4.1-r1.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/lxc-0.7.4.1.ebuild,v 1.1 2011/03/30 12:09:06 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/lxc-0.7.4.1-r1.ebuild,v 1.1 2011/04/24 15:24:44 flameeyes Exp $
EAPI="2"