vtest-init-lxc is more strict when checking if container already exists
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Sun, 1 Apr 2012 13:12:05 +0000 (15:12 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Sun, 1 Apr 2012 13:12:05 +0000 (15:12 +0200)
vbuild-init-lxc.sh

index 82db67e..fa7d1a1 100755 (executable)
@@ -860,11 +860,9 @@ function main () {
     # need lxc installed before we can run lxc-ls
     prepare_host
     
-    if [ ! -z "$(lxc-ls | grep $lxc)" ];then
-        echo "container $lxc exists"
-        exit 1
-    fi
-
+    # be strict on lxc-lines matching name exactly using ^<name>$
+    # as otherwise the timestamps may show up here
+    lxc-ls | grep -q '^'"$lxc"'$' && { echo "container $lxc already exists - exiting" ; exit 1 ; }
     
     path=/var/lib/lxc
     rootfs_path=$path/$lxc/rootfs