Commit fe253caa by Stéphane Graber

templates: Consistent use of locking

Move to per-template lock (except for oracle that's per-container). Also ensure that the path used for the lock is relative to LOCALSTATEDIR. Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 75350ec8
...@@ -228,7 +228,7 @@ install_altlinux() ...@@ -228,7 +228,7 @@ install_altlinux()
return 1 return 1
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
return $? return $?
} }
...@@ -325,7 +325,7 @@ clean() ...@@ -325,7 +325,7 @@ clean()
echo -n "Purging the download cache for ALTLinux-$release..." echo -n "Purging the download cache for ALTLinux-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
} }
usage() usage()
......
...@@ -191,7 +191,7 @@ install_debian() ...@@ -191,7 +191,7 @@ install_debian()
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian
return $? return $?
} }
...@@ -261,7 +261,7 @@ clean() ...@@ -261,7 +261,7 @@ clean()
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian
} }
usage() usage()
......
...@@ -233,7 +233,7 @@ install_fedora() ...@@ -233,7 +233,7 @@ install_fedora()
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-fedora
return $? return $?
} }
...@@ -301,7 +301,7 @@ clean() ...@@ -301,7 +301,7 @@ clean()
echo -n "Purging the download cache for Fedora-$release..." echo -n "Purging the download cache for Fedora-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-fedora
} }
usage() usage()
......
...@@ -166,7 +166,7 @@ install_debian() ...@@ -166,7 +166,7 @@ install_debian()
return 1 return 1
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-lenny
return $? return $?
} }
...@@ -234,7 +234,7 @@ clean() ...@@ -234,7 +234,7 @@ clean()
echo -n "Purging the download cache..." echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-lenny
} }
usage() usage()
......
...@@ -242,7 +242,7 @@ install_opensuse() ...@@ -242,7 +242,7 @@ install_opensuse()
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
return $? return $?
} }
...@@ -314,7 +314,7 @@ clean() ...@@ -314,7 +314,7 @@ clean()
echo -n "Purging the download cache..." echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
} }
usage() usage()
......
...@@ -337,7 +337,7 @@ container_rootfs_create() ...@@ -337,7 +337,7 @@ container_rootfs_create()
fi fi
done done
mkdir -p /var/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/lxc
( (
flock -x 200 flock -x 200
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -433,7 +433,7 @@ container_rootfs_create() ...@@ -433,7 +433,7 @@ container_rootfs_create()
echo "Rebuilding rpm database" echo "Rebuilding rpm database"
rm -f $container_rootfs/var/lib/rpm/__db* rm -f $container_rootfs/var/lib/rpm/__db*
chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1 chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1
) 200>/var/lock/subsys/lxc-oracle-$name ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-oracle-$name
} }
usage() usage()
......
...@@ -395,7 +395,7 @@ EOF ...@@ -395,7 +395,7 @@ EOF
echo "If you do not have a meta-data service, this container will likely be useless." echo "If you do not have a meta-data service, this container will likely be useless."
fi fi
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-ubucloud ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-ubuntu-cloud
copy_configuration $path $rootfs $name $arch $release copy_configuration $path $rootfs $name $arch $release
......
...@@ -259,7 +259,7 @@ install_ubuntu() ...@@ -259,7 +259,7 @@ install_ubuntu()
release=$2 release=$2
flushcache=$3 flushcache=$3
cache="@LOCALSTATEDIR@/cache/lxc/$release" cache="@LOCALSTATEDIR@/cache/lxc/$release"
mkdir -p /var/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 200
...@@ -293,7 +293,7 @@ install_ubuntu() ...@@ -293,7 +293,7 @@ install_ubuntu()
return 0 return 0
) 200>/var/lock/subsys/lxc ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-ubuntu
return $? return $?
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment