renamed native-shell.pkgs into vtest.pkgs
[build.git] / vbuild-init-vserver.sh
index 8b21957..d1b44b5 100755 (executable)
@@ -55,7 +55,7 @@ function configure_yum_in_vserver () {
        else
             # exclude kernel from fedora repos 
            for i in /vservers/$vserver/etc/yum.repos.d/* ; do
-               echo "exclude=kernel* ulogd iptables" >> $i
+               [ -f $i ] && echo "exclude=kernel* ulogd iptables" >> $i
            done
            # the build repo is not signed at this stage
            cat > /vservers/$vserver/etc/yum.repos.d/myplc.repo <<EOF
@@ -105,7 +105,8 @@ function setup_vserver () {
     fi
 
     if [ -n "$VBUILD_MODE" ] ; then 
-    # set up appropriate vserver capabilities to mount, mknod and IPC_LOCK
+       ### capabilities required for a build vserver
+        # set up appropriate vserver capabilities to mount, mknod and IPC_LOCK
        BCAPFILE=/etc/vservers/$vserver/bcapabilities
        touch $BCAPFILE
        cap=$(grep ^CAP_SYS_ADMIN /etc/vservers/$vserver/bcapabilities | wc -l)
@@ -114,6 +115,11 @@ function setup_vserver () {
        [ $cap -eq 0 ] && echo 'CAP_MKNOD' >> /etc/vservers/$vserver/bcapabilities
        cap=$(grep ^CAP_IPC_LOCK /etc/vservers/$vserver/bcapabilities | wc -l)
        [ $cap -eq 0 ] && echo 'CAP_IPC_LOCK' >> /etc/vservers/$vserver/bcapabilities
+    else
+       ### capabilities required for a myplc vserver
+       # for /etc/plc.d/gpg - need to init /dev/random
+       cap=$(grep ^CAP_MKNOD /etc/vservers/$vserver/bcapabilities | wc -l)
+       [ $cap -eq 0 ] && echo 'CAP_MKNOD' >> /etc/vservers/$vserver/bcapabilities
     fi
 
     $personality vyum $vserver -- -y install yum
@@ -121,7 +127,7 @@ function setup_vserver () {
 
     # start the vserver so we can do the following operations
     $personality vserver $VERBOSE $vserver start
-    $personality vserver $VERBOSE $vserver exec rm -f /var/lib/rpm/__db*
+    $personality vserver $VERBOSE $vserver exec sh -c "rm -f /var/lib/rpm/__db*"
     $personality vserver $VERBOSE $vserver exec rpm --rebuilddb
 
     # minimal config in the vserver for yum to work
@@ -146,7 +152,7 @@ function devel_tools () {
     if [ -n "$VBUILD_MODE" ] ; then
        pkgsname=devel.pkgs
     else
-       pkgsname=native-shell.pkgs
+       pkgsname=vtest.pkgs
     fi
     pkgsfile=$(pl_locateDistroFile $DIRNAME $pldistro $pkgsname)
 
@@ -247,23 +253,23 @@ EOF
 }
 
 COMMAND_VBUILD="vbuild-init-vserver.sh"
-COMMAND_MYPLC="myplc-init-vserver.sh"
+COMMAND_MYPLC="vtest-init-vserver.sh"
 function usage () {
     set +x 
-    echo "Usage: $COMMAND_VBUILD [-v] vserver-name [ -- vserver-options ]"
-    echo "Usage: $COMMAND_MYPLC [-v] vserver-name repo-url [ -- vserver-options ]"
+    echo "Usage: $COMMAND_VBUILD [options] vserver-name [ -- vserver-options ]"
+    echo "Usage: $COMMAND_MYPLC [options] vserver-name repo-url [ -- vserver-options ]"
     echo "Requirements: you need to have a vserver-compliant kernel,"
-    echo "  as well as the util-vserver RPM installed"
+    echo "   as well as the util-vserver RPM installed"
     echo "Description:"
-    echo "  This command creates a fresh vserver instance, for building, or running, myplc"
+    echo "   This command creates a fresh vserver instance, for building, or running, myplc"
     echo "Supported options"
     echo " -f fcdistro - for creating the root filesystem - defaults to $DEFAULT_FCDISTRO"
     echo " -d pldistro - defaults to $DEFAULT_PLDISTRO"
     echo " -p personality - defaults to $DEFAULT_PERSONALITY"
-    echo " -v : passes -v to calls to vserver"
+    echo " -v : verbose - passes -v to calls to vserver"
     echo "vserver-options"
-    echo " all args after the optional -- are passed to vserver <name> build <options>"
-    echo " typical usage is e.g. --interface eth0:200.150.100.10/24"
+    echo "  all args after the optional -- are passed to vserver <name> build <options>"
+    echo "  typical usage is e.g. --interface eth0:200.150.100.10/24"
     exit 1
 }