[packages/lxc] Release 3. Fixes in init scripts.

matkor matkor at pld-linux.org
Wed Feb 25 13:20:44 CET 2015


commit 72d9317d6517f2ac0a75c4eec1c9a30db1ebb604
Author: Mateusz Korniak <matkor at pld-linux.org>
Date:   Wed Feb 25 13:20:20 2015 +0100

    Release 3. Fixes in init scripts.

 lxc.init         | 27 +++++++++------------------
 lxc.spec         | 10 ++++++----
 lxc_macvlan.init | 10 +++++++++-
 3 files changed, 24 insertions(+), 23 deletions(-)
---
diff --git a/lxc.spec b/lxc.spec
index 1c0e53f..d53cc13 100644
--- a/lxc.spec
+++ b/lxc.spec
@@ -13,7 +13,7 @@ Summary:	Linux Containers userspace tools
 Summary(pl.UTF-8):	Narzędzia do kontenerów linuksowych (LXC)
 Name:		lxc
 Version:	1.0.7
-Release:	2
+Release:	3
 License:	LGPL v2.1+
 Group:		Applications/System
 Source0:	https://www.linuxcontainers.org/downloads/%{name}-%{version}.tar.gz
@@ -42,6 +42,9 @@ BuildRequires:	rpmbuild(macros) >= 1.612
 BuildRequires:	sed >= 4.0
 Requires:	rc-scripts >= 0.4.6
 Requires:	which
+Requires:	iproute2
+Requires(post,preun):	/sbin/chkconfig
+Requires(post):	/sbin/ldconfig
 Suggests:	gnupg
 Suggests:	gnupg-plugin-keys_curl
 Suggests:	gnupg-plugin-keys_hkp
@@ -190,12 +193,11 @@ install -p %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/lxc_macvlan
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post	-p /sbin/ldconfig
+%post	
+/sbin/ldconfig
 /sbin/chkconfig --add lxc
 /sbin/chkconfig --add lxc_macvlan
 
-# %service lxc restart
-
 %preun
 if [ "$1" = "0" ]; then
 	%service lxc stop
diff --git a/lxc.init b/lxc.init
index 0b8a0a0..2a134e2 100755
--- a/lxc.init
+++ b/lxc.init
@@ -41,7 +41,9 @@ OPTIONS=
 
 # STOPOPTS are stop options.  The can be used for anything else to stop.
 #	If you want to kill containers fast, use -k
-STOPOPTS="-a -s"
+# --all         list all auto-started containers (ignore groups)
+# --shutdown    shutdown the containers instead of starting them
+STOPOPTS="--all --shutdown"
 
 # Source function library.
 test ! -r "$sysconfdir"/rc.d/init.d/functions ||
@@ -98,16 +100,9 @@ case "$1" in
 	fi
 
 	# Start containers
-	## wait_for_bridge
-	# Start autoboot containers first then the NULL group "onboot,".
-	## action $"Starting LXC autoboot containers: " /usr/bin/lxc-autostart $OPTIONS $BOOTGROUPS
-	## msg_starting lxc
-	## echo "DEBUG: Launch: /usr/bin/lxc-autostart $OPTIONS $BOOTGROUPS"
-	CONTAINERS_LIST=`/usr/bin/lxc-autostart $OPTIONS $BOOTGROUPS --list`
-
-        ## run_cmd "Starting LXC containers ( $CONTAINERS_LIST ) from groups: $BOOTGROUPS " /usr/bin/lxc-autostart $OPTIONS $BOOTGROUPS 
-        run_cmd $(nls "Starting LXC containers (%s) from groups: %s " $CONTAINERS_LIST $BOOTGROUPS) /usr/bin/lxc-autostart $OPTIONS $BOOTGROUPS
-
+	CONTAINERS_LIST=`/usr/bin/lxc-autostart $OPTIONS $BOOTGROUPS --list | tr '\n' ' '`
+	# echo "DEBUG: CONTAINERS_LIST=${CONTAINERS_LIST}"
+        run_cmd "$(nls "Starting LXC containers (%s) from groups: %s " "$CONTAINERS_LIST" "$BOOTGROUPS")" /usr/bin/lxc-autostart $OPTIONS $BOOTGROUPS
 	touch "$localstatedir"/lock/subsys/lxc
 	;;
   stop)
@@ -119,12 +114,8 @@ case "$1" in
 	# The stop is serialized and can take excessive time.  We need to avoid
 	# delaying the system shutdown / reboot as much as we can since it's not
 	# parallelized...  Even 5 second timout may be too long.
-	## action $"Stopping LXC containers: " "$bindir"/lxc-autostart $STOPOPTS $SHUTDOWNDELAY
-	CONTAINERS_LIST=`/usr/bin/lxc-autostart $STOPOPTS --list`
-
-	## run_cmd "Stopping running LXC containers ($CONTAINERS_LIST) "   "$bindir"/lxc-autostart $STOPOPTS $SHUTDOWNDELAY
-	run_cmd $(nls "Stopping running LXC containers (%s) " $CONTAINERS_LIST) /usr/bin/lxc-autostart $STOPOPTS $SHUTDOWNDELAY
-
+	CONTAINERS_LIST=`/usr/bin/lxc-autostart $STOPOPTS --list | tr '\n' ' '`
+	run_cmd "$(nls "Stopping running LXC containers (%s) " "$CONTAINERS_LIST")" /usr/bin/lxc-autostart $STOPOPTS $SHUTDOWNDELAY
 	rm -f "$localstatedir"/lock/subsys/lxc
 	;;
   restart|reload|force-reload)
@@ -132,7 +123,7 @@ case "$1" in
 	$0 start
 	;;
   status)
-	lxc-ls --fancy   # NOTE: python3-lxc is needed for lxc-ls
+	lxc-ls --fancy  --fancy-format name,state,pid,ipv4,ipv6,memory,ram,swap    # NOTE: python3-lxc is needed for lxc-ls
 	;;
   *)
 	echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
diff --git a/lxc_macvlan.init b/lxc_macvlan.init
index f2f9b10..ea70326 100755
--- a/lxc_macvlan.init
+++ b/lxc_macvlan.init
@@ -39,12 +39,14 @@ fi
 # If not defined MACVLAN_HWADDRESS, calculate it from MACVLAN_ADDRESS
 if [ -z "$MACVLAN_HWADDRESS" ]; then 
     MACVLAN_HWADDRESS=`echo $MACVLAN_ADDRESS | awk -F "/" '{print $1}' | awk -F "." '{ printf "00:16:3e:%x:%x:%x\n", $2, $3, $4 }'`
-    echo "MACVLAN_HWADDRESS not set, using calculated from MACVLAN_ADDRESS=${MACVLAN_ADDRESS} value: ${MACVLAN_HWADDRESS}"; 
+    # TODO: Print on start() only
+    # echo "MACVLAN_HWADDRESS not set, using calculated from MACVLAN_ADDRESS=${MACVLAN_ADDRESS} value: ${MACVLAN_HWADDRESS}"; 
 fi
 
 
 start() {
         msg_starting "LXC macvlan interface"
+	# set -x
 	ip link add link $MACVLAN_DEV name $MACVLAN_NAME address $MACVLAN_HWADDRESS type macvlan mode bridge
 	ip link set $MACVLAN_NAME up
 	ip address add $MACVLAN_ADDRESS brd + dev $MACVLAN_NAME
@@ -57,12 +59,17 @@ start() {
 
 stop() {
         msg_stopping "LXC macvlan interface"
+	# set -x
 	ip link set $MACVLAN_NAME down
 	ip link del $MACVLAN_NAME
         RETVAL=$?
 	[ $RETVAL -eq 0 ] && ok || fail
 }
 
+status() {
+	ip addr show $MACVLAN_NAME 
+}
+
 
 RETVAL=0
 
@@ -80,6 +87,7 @@ case "$1" in
 	start
 	;;
   status)
+	status
 	;;
   *)
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/lxc.git/commitdiff/72d9317d6517f2ac0a75c4eec1c9a30db1ebb604



More information about the pld-cvs-commit mailing list