X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vbuild-init-vserver.sh;h=7aed8179af4e188329654c9eb7326851632432ea;hb=refs%2Fheads%2Flxc_devel;hp=4a6497183fc77b64a35999442cef954423c58852;hpb=d996e9e16a8250467145f4520785f01cb82604fb;p=build.git diff --git a/vbuild-init-vserver.sh b/vbuild-init-vserver.sh index 4a649718..7aed8179 100755 --- a/vbuild-init-vserver.sh +++ b/vbuild-init-vserver.sh @@ -102,6 +102,15 @@ function canonical_arch () { esac } +# the new test framework creates /timestamp in /vservers/ *before* populating it +function almost_empty () { + dir="$1"; shift ; + # non existing is fine + [ ! -d $dir ] && return 0; + # need to have at most one file + count=$(cd $dir; ls | wc -l); [ $count -le 1 ]; +} + function setup_vserver () { set -x @@ -112,10 +121,11 @@ function setup_vserver () { fcdistro=$1; shift personality=$1; shift - if [ -d /vservers/$vserver ] ; then + # check that this is a new one - see above + almost_empty /vservers/$vserver || { echo "$COMMAND : vserver $vserver seems to exist - bailing out" exit 1 - fi + } pkg_method=$(package_method $fcdistro) case $pkg_method in @@ -139,8 +149,8 @@ function setup_vserver () { echo "* ${i}-th attempt to 'vserver build' failed - waiting for 3 seconds" sleep 3 done - # check success - [ -d /vservers/$vserver ] + # check success - not enough to check for the directory, let's assume /etc/ in image + [ -d /vservers/$vserver/etc ] if [ ! -z "$personality" ] ; then if [ -f "/etc/vservers/$vserver/personality" ] ; then @@ -161,14 +171,14 @@ function setup_vserver () { grep -q ^CAP_SYS_ADMIN $BCAPFILE || echo CAP_SYS_ADMIN >> $BCAPFILE grep -q ^CAP_MKNOD $BCAPFILE || echo CAP_MKNOD >> $BCAPFILE grep -q ^CAP_IPC_LOCK $BCAPFILE || echo CAP_IPC_LOCK >> $BCAPFILE - # useful for f15 guests that use set_cap_file + # useful for f16 guests that use set_cap_file grep -q ^CAP_SETFCAP $BCAPFILE || echo CAP_SETFCAP >> $BCAPFILE else ### capabilities required for a myplc vserver # for /etc/plc.d/gpg - need to init /dev/random grep -q ^CAP_MKNOD $BCAPFILE || echo CAP_MKNOD >> $BCAPFILE grep -q ^CAP_NET_BIND_SERVICE $BCAPFILE || echo CAP_NET_BIND_SERVICE >> $BCAPFILE - # useful for f15 guests that use set_cap_file + # useful for f16 guests that use set_cap_file grep -q ^CAP_SETFCAP $BCAPFILE || echo CAP_SETFCAP >> $BCAPFILE fi @@ -182,11 +192,8 @@ function setup_vserver () { # Enable cgroup mkdir /etc/vservers/$vserver/cgroup - # Start Vserver automatically on boot - echo "default" > /etc/vservers/$vserver/apps/init/mark - - # Set the init style of your vserver to plain for f15 and higher - # not working with f15 anyways, systemd requires 2.6.36 to work + # Set the init style of your vserver to plain for f16 and higher + # not working with f16 anyways, systemd requires 2.6.36 to work case $fcdistro in f1[5-9]) echo plain > /etc/vservers/$vserver/apps/init/style ;; esac @@ -451,6 +458,7 @@ function usage () { echo " -d pldistro - defaults to $DEFAULT_PLDISTRO" echo " -p personality - defaults to $DEFAULT_PERSONALITY" echo " -i ifname: determines ip and netmask attached to ifname, and passes it to the vserver" + echo " -r : set apps/init/mark to default so the vserver restart upon reboot" echo " -v : verbose - passes -v to calls to vserver" echo "vserver-options" echo " all args after the optional -- are passed to vserver build " @@ -476,14 +484,16 @@ function main () { esac VERBOSE= + RESISTANT="" IFNAME="" VSERVER_OPTIONS="" - while getopts "f:d:p:i:v" opt ; do + while getopts "f:d:p:i:rv" opt ; do case $opt in f) fcdistro=$OPTARG;; d) pldistro=$OPTARG;; p) personality=$OPTARG;; i) IFNAME=$OPTARG;; + r) RESISTANT="true";; v) VERBOSE="-v" ;; *) usage ;; esac @@ -526,6 +536,10 @@ function main () { devel_or_vtest_tools $vserver $fcdistro $pldistro $personality post_install $vserver $personality + # Start Vserver automatically on boot + [ -n "$RESISTANt" ] && echo "default" > /etc/vservers/$vserver/apps/init/mark + + echo $COMMAND Done } main "$@"