public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2010-08-01  3:17 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2010-08-01  3:17 UTC (permalink / raw
  To: gentoo-commits

flameeyes    10/08/01 03:17:51

  Added:                lxc.initd
  Log:
  Version bump, add the long-requested init script (protected with a USE=vanilla for those preferring not to have it).
  (Portage version: 2.2_rc67/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.1&content-type=text/plain

Index: lxc.initd
===================================================================
#!/sbin/runscript
# Copyright 1999-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 $

CONTAINER=${SVCNAME#*.}
CONFIGFILE=${CONFIGFILE:-/etc/lxc/${CONTAINER}.conf}

depend() {
	 need net.lo localmount
}

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
}

rootpath() {
    sed -n -e 's:^[ \t]*lxc.rootfs[ \t]*=[ \t]*\(.*\)$:\1:p' ${CONFIGFILE}
}

start() {
    checkconfig || return 1

    rm /var/log/lxc/${CONTAINER}.log

    # 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

    mkdir -p /var/log/lxc

    ebegin "Starting ${CONTAINER}"
    ${setarch} lxc-start -n ${CONTAINER} -f ${CONFIGFILE} -d -o /var/log/lxc/${CONTAINER}.log
    eend $?
}

stop() {
    checkconfig || return 1

    local init_pid=$(head -n1 /cgroup/${CONTAINER}/tasks)

    ebegin "Shutting down system in ${CONTAINER}"
    kill -INT ${init_pid}
    eend $?

    sleep 15

    missingprocs=$(pgrep -P ${init_pid})

    if [ -n "${missingprocs}" ]; then
	ewarn "Something failed to properly shut down in ${CONTAINER}"
    fi

    ebegin "Stopping ${CONTAINER}"
    lxc-stop -n ${CONTAINER}
    eend $?
}







^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2010-08-01 21:13 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2010-08-01 21:13 UTC (permalink / raw
  To: gentoo-commits

flameeyes    10/08/01 21:13:46

  Modified:             lxc.initd
  Log:
  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).
  (Portage version: 2.2_rc67/cvs/Linux x86_64)

Revision  Changes    Path
1.2                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.1&r2=1.2

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- lxc.initd	1 Aug 2010 03:17:51 -0000	1.1
+++ lxc.initd	1 Aug 2010 21:13:46 -0000	1.2
@@ -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 @@
 	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 @@
     lxc-stop -n ${CONTAINER}
     eend $?
 }
-






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2011-02-26 18:02 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2011-02-26 18:02 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/02/26 18:02:51

  Modified:             lxc.initd
  Log:
  Version bump; update warnings (configuration is now back to 0.7.2 syntax); make sure the init script logs warnings, as otherwise you'll never know what's going on.
  
  (Portage version: 2.2.0_alpha25/cvs/Linux x86_64)

Revision  Changes    Path
1.3                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.3&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.3&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.2&r2=1.3

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- lxc.initd	1 Aug 2010 21:13:46 -0000	1.2
+++ lxc.initd	26 Feb 2011 18:02:51 -0000	1.3
@@ -1,7 +1,7 @@
 #!/sbin/runscript
-# Copyright 2010-2010 Gentoo Foundation
+# 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.2 2010/08/01 21:13:46 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.3 2011/02/26 18:02:51 flameeyes Exp $
 
 CONTAINER=${SVCNAME#*.}
 CONFIGFILE=${CONFIGFILE:-/etc/lxc/${CONTAINER}.conf}
@@ -75,7 +75,7 @@
     esac
 
     ebegin "Starting ${CONTAINER}"
-    ${setarch} lxc-start -n ${CONTAINER} -f ${CONFIGFILE} -d -o /var/log/lxc/${CONTAINER}.log
+    ${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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2011-04-24 15:24 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2011-04-24 15:24 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/04/24 15:24:44

  Modified:             lxc.initd
  Log:
  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)

Revision  Changes    Path
1.4                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.4&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.4&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.3&r2=1.4

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- lxc.initd	26 Feb 2011 18:02:51 -0000	1.3
+++ lxc.initd	24 Apr 2011 15:24:44 -0000	1.4
@@ -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 @@
 	# 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
+	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 $?
+	# 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 $?
 }






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2011-05-06 11:03 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2011-05-06 11:03 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/05/06 11:03:46

  Modified:             lxc.initd
  Log:
  Reset the environment when starting the container so that its environment is picked up entirely.
  
  (Portage version: 2.2.0_alpha30/cvs/Linux x86_64)

Revision  Changes    Path
1.5                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.5&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.5&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.4&r2=1.5

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- lxc.initd	24 Apr 2011 15:24:44 -0000	1.4
+++ lxc.initd	6 May 2011 11:03:46 -0000	1.5
@@ -1,7 +1,7 @@
 #!/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.4 2011/04/24 15:24:44 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.5 2011/05/06 11:03:46 flameeyes Exp $
 
 CONTAINER=${SVCNAME#*.}
 CONFIGFILE=${CONFIGFILE:-/etc/lxc/${CONTAINER}.conf}
@@ -93,7 +93,7 @@
 	esac
 
 	ebegin "Starting ${CONTAINER}"
-	${setarch} lxc-start -l WARN -n ${CONTAINER} -f $(lxc_get_configfile) -d -o /var/log/lxc/${CONTAINER}.log
+	env -i ${setarch} $(type -p 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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2011-09-05 18:32 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2011-09-05 18:32 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/09/05 18:32:44

  Modified:             lxc.initd
  Log:
  Version bump; also includes fixes for the init script, closing bugs #379679 and #379683 by George Georgiev.
  
  (Portage version: 2.2.0_alpha53/cvs/Linux x86_64)

Revision  Changes    Path
1.6                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.6&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.6&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.5&r2=1.6

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- lxc.initd	6 May 2011 11:03:46 -0000	1.5
+++ lxc.initd	5 Sep 2011 18:32:44 -0000	1.6
@@ -1,15 +1,12 @@
 #!/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.5 2011/05/06 11:03:46 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.6 2011/09/05 18:32: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
+	if [ -f "/etc/lxc/${CONTAINER}.conf" ]; then
 		echo "/etc/lxc/${CONTAINER}.conf"
 	elif [ -f "/etc/lxc/${CONTAINER}/config" ]; then
 		echo "/etc/lxc/${CONTAINER}/config"
@@ -21,8 +18,10 @@
 	fi
 }
 
+CONFIGFILE=${CONFIGFILE:-$(lxc_get_configfile)}
+
 lxc_get_var() {
-	awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' $(lxc_get_configfile)
+	awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE}
 }
 
 cgroup_get_mount() {
@@ -37,7 +36,7 @@
 	fi
 
 	# no need to output anything, the function takes care of that.
-	[ -z "$(lxc_get_configfile)" ] && return 1
+	[ -z "${CONFIGFILE}" ] && return 1
 
 	utsname=$(lxc_get_var lxc.utsname)
 	if [ ${CONTAINER} != ${utsname} ]; then
@@ -52,14 +51,14 @@
 	# non-muxed init script, unfortunately.
 	checkconfig 2>/dev/null || return 0
 
-	config $(lxc_get_configfile)
+	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}
+	[ -n "${netif}" ] && use net.${netif}
 }
 
 start() {
@@ -93,7 +92,7 @@
 	esac
 
 	ebegin "Starting ${CONTAINER}"
-	env -i ${setarch} $(type -p lxc-start) -l WARN -n ${CONTAINER} -f $(lxc_get_configfile) -d -o /var/log/lxc/${CONTAINER}.log
+	env -i ${setarch} $(type -p 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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2011-09-14 19:39 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2011-09-14 19:39 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/09/14 19:39:40

  Modified:             lxc.initd
  Log:
  Fix init script not to look for a configuration file when generating dependencies for the base (multiplexed) init script. Revision bump to make sure users reinstall the ebuild, and remove old. Closes bug #382519.
  
  (Portage version: 2.2.0_alpha56/cvs/Linux x86_64)

Revision  Changes    Path
1.7                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.7&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.7&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.6&r2=1.7

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- lxc.initd	5 Sep 2011 18:32:44 -0000	1.6
+++ lxc.initd	14 Sep 2011 19:39:40 -0000	1.7
@@ -1,7 +1,7 @@
 #!/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.6 2011/09/05 18:32:44 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.7 2011/09/14 19:39:40 flameeyes Exp $
 
 CONTAINER=${SVCNAME#*.}
 
@@ -18,7 +18,7 @@
 	fi
 }
 
-CONFIGFILE=${CONFIGFILE:-$(lxc_get_configfile)}
+[ $CONTAINER != $SVCNAME ] && CONFIGFILE=${CONFIGFILE:-$(lxc_get_configfile)}
 
 lxc_get_var() {
 	awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE}






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2011-09-28 21:47 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2011-09-28 21:47 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/09/28 21:47:46

  Modified:             lxc.initd
  Log:
  Fix init script to find the correct PID for the container's init and use a 30-seconds timeout to see if it has stopped correctly. Thanks to Stef Simoens for both (bug #384265).
  
  (Portage version: 2.2.0_alpha59/cvs/Linux x86_64)

Revision  Changes    Path
1.8                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.8&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.8&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.7&r2=1.8

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- lxc.initd	14 Sep 2011 19:39:40 -0000	1.7
+++ lxc.initd	28 Sep 2011 21:47:46 -0000	1.8
@@ -1,7 +1,7 @@
 #!/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.7 2011/09/14 19:39:40 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.8 2011/09/28 21:47:46 flameeyes Exp $
 
 CONTAINER=${SVCNAME#*.}
 
@@ -111,15 +111,19 @@
 	    return 0
 	fi
 
-	init_pid=$(head -n1 ${cgroupmount}/${CONTAINER}/tasks)
+	init_pid=$(lxc-info -n ${CONTAINER} --pid | cut -d: -f 2)
 
 	ebegin "Shutting down system in ${CONTAINER}"
 	kill -INT ${init_pid}
 	eend $?
 
-	sleep 15
-
-	missingprocs=$(pgrep -P ${init_pid})
+	TIMEOUT=${TIMEOUT:-30}
+	i=0
+	while [ -n "${missingprocs}" -a $i -lt ${TIMEOUT} ]; do
+		sleep 1
+		missingprocs=$(pgrep -P ${init_pid})
+		i=$(expr $i + 1)
+	done
 
 	if [ -n "${missingprocs}" ]; then
 		ewarn "Something failed to properly shut down in ${CONTAINER}"






^ permalink raw reply	[flat|nested] 9+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd
@ 2011-10-19 17:51 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 9+ messages in thread
From: Diego Petteno (flameeyes) @ 2011-10-19 17:51 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/10/19 17:51:49

  Modified:             lxc.initd
  Log:
  Revision bump to fix two issues with the init script reported by Alexander Y. Fomichev (bug #387675 and #387679).
  
  (Portage version: 2.2.0_alpha69/cvs/Linux x86_64)

Revision  Changes    Path
1.9                  app-emulation/lxc/files/lxc.initd

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.9&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?rev=1.9&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/lxc/files/lxc.initd?r1=1.8&r2=1.9

Index: lxc.initd
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- lxc.initd	28 Sep 2011 21:47:46 -0000	1.8
+++ lxc.initd	19 Oct 2011 17:51:48 -0000	1.9
@@ -1,7 +1,7 @@
 #!/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.8 2011/09/28 21:47:46 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/lxc/files/lxc.initd,v 1.9 2011/10/19 17:51:48 flameeyes Exp $
 
 CONTAINER=${SVCNAME#*.}
 
@@ -113,15 +113,19 @@
 
 	init_pid=$(lxc-info -n ${CONTAINER} --pid | cut -d: -f 2)
 
+	if [ "${init_pid}" = "-1" ]; then
+	    ewarn "${CONTAINER} doesn't seem to be running."
+	    return 0
+	fi
+
 	ebegin "Shutting down system in ${CONTAINER}"
 	kill -INT ${init_pid}
 	eend $?
 
 	TIMEOUT=${TIMEOUT:-30}
 	i=0
-	while [ -n "${missingprocs}" -a $i -lt ${TIMEOUT} ]; do
+	while [ -n "$(pgrep -P ${init_pid})" -a $i -lt ${TIMEOUT} ]; do
 		sleep 1
-		missingprocs=$(pgrep -P ${init_pid})
 		i=$(expr $i + 1)
 	done
 






^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-10-19 17:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-24 15:24 [gentoo-commits] gentoo-x86 commit in app-emulation/lxc/files: lxc.initd Diego Petteno (flameeyes)
  -- strict thread matches above, loose matches on Subject: below --
2011-10-19 17:51 Diego Petteno (flameeyes)
2011-09-28 21:47 Diego Petteno (flameeyes)
2011-09-14 19:39 Diego Petteno (flameeyes)
2011-09-05 18:32 Diego Petteno (flameeyes)
2011-05-06 11:03 Diego Petteno (flameeyes)
2011-02-26 18:02 Diego Petteno (flameeyes)
2010-08-01 21:13 Diego Petteno (flameeyes)
2010-08-01  3:17 Diego Petteno (flameeyes)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox