From 78ed9f1272859f95a55763d5807b1e6276dc6a14 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 26 Mar 2014 12:04:18 +0100 Subject: [PATCH] an attempt to make VM creation more robust, as more often than expected we fail that step because of this lock thing --- lbuild-initvm.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lbuild-initvm.sh b/lbuild-initvm.sh index c65026c8..ee03232e 100755 --- a/lbuild-initvm.sh +++ b/lbuild-initvm.sh @@ -104,13 +104,12 @@ function fedora_install() { cache=/var/cache/lxc/fedora/$arch/$release - mkdir -p /var/lock/subsys/ ( - flock -n -x 200 || { echo "Cache repository is busy." ; return 1 ; } + flock --exclusive --timeout 60 200 || { echo "Cache repository is busy." ; return 1 ; } if [ ! -e "$cache/rootfs" ]; then echo "Getting cache download in $cache/rootfs ... " - fedora_download || { echo "Failed to download 'fedora base'"; return 1; } + fedora_download $cache || { echo "Failed to download 'fedora base'"; return 1; } else echo "Updating cache $cache/rootfs ..." if ! yum --installroot $cache/rootfs -y --nogpgcheck update ; then @@ -120,18 +119,21 @@ function fedora_install() { fi fi - echo "Copy $cache/rootfs to $lxc_root ... " + echo "Filling $lxc_root from $cache/rootfs ... " rsync -a $cache/rootfs/ $lxc_root/ return 0 - ) 200>/var/lock/subsys/lxc + ) 200> $cache/lock return $? } function fedora_download() { set -x + + cache=$1; shift + # check the mini fedora was not already downloaded INSTALL_ROOT=$cache/partial echo $INSTALL_ROOT -- 2.43.0