Subject: [PATCH] support for busybox grep and busybox shell
From: Natanael Copa <natanael.copa@gmail.com>
Date: Fri, 03 Aug 2007 10:26:34 +0200
Fri, 03 Aug 2007 10:26:34 +0200
Hi,

Those patches was needed to be able to run vserver with busybox grep and
busybox ash as shell.

The shell patch should not be needed with the next release of busybox.

There are more issues with busybox (mktemp does not work) but this is a
start.

PS. as a sidenote... it would be awesome if we could get rid of bash and
have POSIX compliant shell code. See the BUGS section in bash manpage. I
would be glad to help out in converting the scripts and get rid of some
other bloat.

Natanael Copa


diff -ruN data.orig/usr/lib/util-vserver/functions data/usr/lib/util-vserver/functions
--- data.orig/usr/lib/util-vserver/functions	2007-07-05 15:41:45 +0000
+++ data/usr/lib/util-vserver/functions	2007-07-09 14:29:25 +0000
@@ -574,7 +574,7 @@
 	set -- $($_GREP '^PROC:' "/proc/virtual/$1/limit" 2>/dev/null)
 	_gp_procnr_cnt=$2
     else
-	_gp_procnr_cnt=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$1" | $_WC -l )
+	_gp_procnr_cnt=$($_VPS ax | $_AWK '{print $2}' | $_GREP "^$1\$" | $_WC -l )
     fi
 
     let _gp_procnr_cnt=_gp_procnr_cnt+0
diff -ruN data.orig/usr/lib/util-vserver/start-vservers data/usr/lib/util-vserver/start-vservers
--- data.orig/usr/lib/util-vserver/start-vservers	2007-07-05 15:41:47 +0000
+++ data/usr/lib/util-vserver/start-vservers	2007-07-09 14:30:04 +0000
@@ -131,7 +131,7 @@
     d=$__CONFDIR/${vservers[$i]}/apps/init
     f=$d/mark
     { test -n "$OPTION_MARK_ANY"; } || \
-    { test -n "$OPTION_MARK" -a -r "$f" && grep -qx "$OPTION_MARK" "$f"; } || \
+    { test -n "$OPTION_MARK" -a -r "$f" && grep -q "^$OPTION_MARK\$" "$f"; } || \
     { test -z "$OPTION_MARK" && test ! -e "$f"; } || \
     unset vservers[$i]
 done


diff -ruN data.orig/usr/lib/util-vserver/vserver.functions data/usr/lib/util-vserver/vserver.functions
--- data.orig/usr/lib/util-vserver/vserver.functions	2007-07-05 15:41:45 +0000
+++ data/usr/lib/util-vserver/vserver.functions	2007-07-10 22:54:08 +0000
@@ -207,7 +207,7 @@
     
     test -n "$ENTER_SHELL" || {
 	local i
-	for i in "/bin/bash -login" "/bin/sh -l" /bin/csh; do
+	for i in "/bin/bash -login" "/bin/ash --login" "/bin/sh -l" /bin/csh; do
 	    set -- $i
 	    test -x "$vdir/vdir/$1" || continue
 	    ENTER_SHELL=( "$@" )