]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
handle interruption/failure of lxc-debian more gracefully
authordlezcano <dlezcano>
Thu, 5 Feb 2009 12:03:47 +0000 (12:03 +0000)
committerdlezcano <dlezcano>
Thu, 5 Feb 2009 12:03:47 +0000 (12:03 +0000)
From: Matt Helsley <matthltc@us.ibm.com>

If lxc-debian fails or is interrupted during debootstrap then the next
invocation of lxc-debian breaks because it only checks for the existence
of the directory. This forces the user to remove the cache by hand to
retry the create step.

Let's allow the user to re-run lxc-debian to resume/retry. Store the
cache in a partial-$ARCH directory until debootstrap succeeds. Then move
the valid cache to its final destination.

Signed-off-by: Matt Helsley <matthltc@us.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
scripts/lxc-debian.in

index 2942edd8ccc050d43535224d1f2cf66f465b025f..428145fa09c089f6de4d1b3fe895005c7309e2cf 100755 (executable)
@@ -212,19 +212,20 @@ create() {
                
                echo "not cached"
                
-               mkdir -p "$CACHE/rootfs-$ARCH"
+               mkdir -p "$CACHE/partial-$ARCH"
                
                # download a mini debian into a cache
                echo "Downloading debian minimal ..."
                debootstrap --verbose --variant=minbase --arch=$ARCH \
                    --include apache,netbase,net-tools,iproute,openssh-server \
-                   etch $CACHE/rootfs-$ARCH http://ftp.debian.org/debian
+                   etch $CACHE/partial-$ARCH http://ftp.debian.org/debian
                
                RESULT=$?
                if [ "$RESULT" != "0" ]; then
                    echo "Failed to download the rootfs, aborting."
                    exit 1
                fi
+               mv "$CACHE/partial-$ARCH" "$CACHE/rootfs-$ARCH"
                echo "Download complete."
            else
                echo "Found."