make the lxc backend option conditional on lxc version

The lxc backend store configuration option is deprecated in lxc3. This
change ensures that the option is no longer rendered in the lxc template
when the version of lxc is greater than or equal to version 3.

Change-Id: I207ed1f89604979e74667ae4c603d36304a6ed53
Signed-off-by: Kevin Carter <kevin@cloudnull.com>
This commit is contained in:
Kevin Carter 2018-10-10 10:47:30 -05:00 committed by Kevin Carter (cloudnull)
parent 6405d287ec
commit 6ef6714ca4
1 changed files with 4 additions and 1 deletions

View File

@ -186,17 +186,20 @@ for file in ${TEMPLATE_FILES}; do
done
IFS=${OLD_IFS}
# Add the machinectl backend store for the new containe
# Add the machinectl backend store for the new container
if grep -q '^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} =' "${LXC_PATH}/config"; then
sed -i "s|^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} =.*|{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} = ${LXC_ROOTFS}|" "${LXC_PATH}/config"
else
echo "{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} = ${LXC_ROOTFS}" >> "${LXC_PATH}/config"
fi
{% if (lxc_major_version | int) < 3 %}
if grep -q '^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} =' "${LXC_PATH}/config"; then
sed -i "s|^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} =.*|{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} = btrfs|" "${LXC_PATH}/config"
else
echo "{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} = btrfs" >> "${LXC_PATH}/config"
fi
{% endif %}
# Prevent mingetty from calling vhangup(2)
if [ -f "${LXC_ROOTFS}/etc/init/tty.conf" ]; then