[__lxc_container] handle $empty_conf for --no-default-config correctly

Fixed wrong variable spelling and correct check to remove the tempfile
again (forgotten from 304d974f).
This commit is contained in:
matze 2020-07-12 21:30:44 +02:00
commit 12a6d52a46

View file

@ -132,10 +132,11 @@ LXC
create_opts=""
if [ -f "$__object/parameter/no-default-config" ]; then
# generate a random empty file and append
# maybe work with an nonexistant file - but just be correct
cat <<TMPFILE
empty_conf="\$(mktemp "\${TMPDIR:-/tmp}/cdist__lxc_container-empty-conf.XXXXXXXXXX")"
TMPFILE
create_opts="$create_opts -f \"\$empty_config\""
create_opts="$create_opts -f \"\$empty_conf\""
elif [ -f "$__object/parameter/default-config" ]; then
# append the configuration
@ -163,10 +164,11 @@ TMPFILE
cat <<LXC
lxc-create $LXC_PARAM $backingstore_opts -n "$name" -t "$template" $create_opts -- $template_opts
LXC
# remove empty tempfile
if [ "$empty_config" ]; then
# remove empty tempfile if it was created
if [ -f "$__object/parameter/no-default-config" ]; then
cat <<RM
rm -rf "$empty_config"
rm -rf "\$empty_conf"
RM
fi
fi