using tagged config for gnuradio
[build.git] / vbuild-init-vserver.sh
index 5e3acd5..4c71dd2 100755 (executable)
@@ -2,13 +2,15 @@
 # -*-shell-*-
 # $Id$
 
+#shopt -s huponexit
+
 COMMAND=$(basename $0)
 DIRNAME=$(dirname $0)
 
 # pkgs parsing utilities
 PATH=$(dirname $0):$PATH . build.common
 
-DEFAULT_FCDISTRO=centos5
+DEFAULT_FCDISTRO=f8
 DEFAULT_PLDISTRO=planetlab
 DEFAULT_PERSONALITY=linux32
 DEFAULT_IFNAME=eth0
@@ -32,24 +34,24 @@ function configure_yum_in_vserver () {
     vserver=$1; shift
     fcdistro=$1; shift
 
-    pushd /etc/vservers/.distributions/${fcdistro}
-    if [ -f yum/yum.conf ] ; then
-       echo "Initializing yum.conf in $vserver from $(pwd)/yum"
+    templates=/etc/vservers/.distributions/${fcdistro}
+    if [ -f ${templates}/yum/yum.conf ] ; then
+       echo "Initializing yum.conf in $vserver from ${templates}/yum"
         sed -e "s!@YUMETCDIR@!/etc!g;
                 s!@YUMCACHEDIR@!/var/cache/yum!g;
                 s!@YUMLOGDIR@!/var/log!g;
                 s!@YUMLOCKDIR@!/var/lock!g;
-               " yum/yum.conf > /vservers/$vserver/etc/yum.conf
+               " ${templates}/yum/yum.conf > /vservers/$vserver/etc/yum.conf
 
        # post process the various @...@ variables from this yum.conf file.
     else
        echo "Using $fcdistro default for yum.conf"
     fi
 
-    if [ -d yum.repos.d ] ; then
-       echo "Initializing yum.repos.d in $vserver from $(pwd)/yum.repos.d"
+    if [ -d ${templates}/yum.repos.d ] ; then
+       echo "Initializing yum.repos.d in $vserver from ${templates}/yum.repos.d"
        rm -rf /vservers/$vserver/etc/yum.repos.d
-       tar cf - yum.repos.d | tar -C /vservers/$vserver/etc -xvf -
+       tar -C ${templates} -cf - yum.repos.d | tar -C /vservers/$vserver/etc -xvf -
     else
        echo "Cannot initialize yum.repos.d in $vserver"
     fi
@@ -72,7 +74,6 @@ gpgcheck=0
 EOF
        fi
     fi
-    popd
 }    
 
 # return yum or debootstrap
@@ -181,17 +182,20 @@ function setup_vserver () {
     fi
 
     # start the vserver so we can do the following operations
+#    rm -f /tmp/go*
+#    echo -n ' about to start - WAITING for /tmp/go1' ; while true ; do [ -f /tmp/go1 ] && break || : ; done
     $personality vserver $VERBOSE $vserver start
+#    echo -n ' started - WAITING for /tmp/go2' ; while true ; do [ -f /tmp/go2 ] && break || : ; done
+#if true ; then 
+#    echo SKIPPING for debug --- vserver was started
+#else
     [ "$pkg_method" = "yum" ] && $personality vserver $VERBOSE $vserver exec sh -c "rm -f /var/lib/rpm/__db*"
     [ "$pkg_method" = "yum" ] && $personality vserver $VERBOSE $vserver exec rpm --rebuilddb
 
-    # with vserver 2.3, granting the vserver CAP_MKNOD is not enough
-    # check whether we run vs2.3 or above
-    vs_version=$(uname -a  | sed -e 's,.*[\.\-]vs\([0-9]\)\.\([0-9]\)\..*,\1\2,')
-    # at this stage we have here 22 or 23
-    need_vdevmap=$(( $vs_version >= 23 ))
+    # check if the vserver kernel is using VSERVER_DEVICE (vdevmap) support
+    need_vdevmap=$(grep "CONFIG_VSERVER_DEVICE=y" /boot/config-$(uname -r) | wc -l)
 
-    if [ "$need_vdevmap" == 1 ] ; then
+    if [ $need_vdevmap -eq 1 ] ; then
        ctx=$(cat /etc/vservers/$vserver/context)
        vdevmap --set --xid $ctx --open --create --target /dev/null
        vdevmap --set --xid $ctx --open --create --target /dev/root
@@ -204,6 +208,9 @@ function setup_vserver () {
     cp /etc/resolv.conf /vservers/$vserver/etc/resolv.conf
     # and /etc/hosts for at least localhost
     [ -f /vservers/$vserver/etc/hosts ] || echo "127.0.0.1 localhost localhost.localdomain" > /vservers/$vserver/etc/hosts
+
+#fi
+
 }
 
 function devel_or_vtest_tools () {
@@ -338,6 +345,9 @@ function post_install_myplc  () {
     # turn off regular crond, as plc invokes plc_crond
     chkconfig crond off
 
+    # take care of loginuid in /etc/pam.d 
+    sed -i "s,#*\(.*loginuid.*\),#\1," /etc/pam.d/*
+
     # customize root's prompt
     cat << PROFILE > /root/.profile
 export PS1="[$vserver] \\w # "