]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
ubuntu: Check that btrfs is actually available
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 15 Aug 2014 23:59:45 +0000 (19:59 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 15 Aug 2014 23:59:45 +0000 (19:59 -0400)
Before calling btrfs and playing with subvolumes, let's make sure the
btrfs command is available.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
templates/lxc-ubuntu.in

index 43d4817558b3420e4dda943ac49c5786967c3d1f..7768357727622ca890a70f58383fd18ed2ff4d3c 100644 (file)
@@ -63,7 +63,7 @@ try_mksubvolume()
     path=$1
     [ -d $path ] && return 0
     mkdir -p $(dirname $path)
-    if is_btrfs $(dirname $path); then
+    if which btrfs >/dev/null 2>&1 && is_btrfs $(dirname $path); then
         btrfs subvolume create $path
     else
         mkdir -p $path
@@ -74,7 +74,7 @@ try_rmsubvolume()
 {
     path=$1
     [ -d $path ] || return 0
-    if is_btrfs_subvolume $path; then
+    if which btrfs >/dev/null 2>&1 && is_btrfs_subvolume $path; then
         btrfs subvolume delete $path
     else
         rm -rf $path
@@ -406,7 +406,7 @@ copy_ubuntu()
     # make a local copy of the miniubuntu
     echo "Copying rootfs to $rootfs ..."
     try_mksubvolume $rootfs
-    if is_btrfs_subvolume $cache/rootfs-$arch && is_btrfs_subvolume $rootfs; then
+    if which btrfs >/dev/null 2>&1 && is_btrfs_subvolume $cache/rootfs-$arch && is_btrfs_subvolume $rootfs; then
       realrootfs=$(dirname $config)/rootfs
       [ "$rootfs" = "$realrootfs" ] || umount $rootfs || return 1
       btrfs subvolume delete $realrootfs || return 1