Merge "Follow up for creating parent dir for config files"
This commit is contained in:
@@ -90,7 +90,6 @@ function merge_config_file {
|
||||
local real_configfile
|
||||
real_configfile=$(eval echo $configfile)
|
||||
if [ ! -f $real_configfile ]; then
|
||||
mkdir -p $(dirname $real_configfile) || die $LINENO "could not create the directory of $real_configfile ($configfile)"
|
||||
touch $real_configfile || die $LINENO "could not create config file $real_configfile ($configfile)"
|
||||
fi
|
||||
|
||||
@@ -186,11 +185,15 @@ function merge_config_group {
|
||||
break
|
||||
fi
|
||||
dir=$(dirname $realconfigfile)
|
||||
if [[ -d $dir ]]; then
|
||||
merge_config_file $localfile $group $configfile
|
||||
else
|
||||
die $LINENO "bogus config file specification $configfile ($configfile=$realconfigfile, $dir is not a directory)"
|
||||
|
||||
test -e $dir && ! test -d $dir && die $LINENO "bogus config file specification $configfile ($configfile=$realconfigfile, $dir exists but it is not a directory)"
|
||||
|
||||
if ! [[ -e $dir ]] ; then
|
||||
sudo mkdir -p $dir || die $LINENO "could not create the directory of $real_configfile ($configfile)"
|
||||
sudo chown ${STACK_USER} $dir
|
||||
fi
|
||||
|
||||
merge_config_file $localfile $group $configfile
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
@@ -137,6 +137,9 @@ foo=bar
|
||||
[some]
|
||||
random=config
|
||||
|
||||
[[test12|run_tests.sh/test.conf]]
|
||||
foo=bar
|
||||
|
||||
[[test-multi-sections|test-multi-sections.conf]]
|
||||
[sec-1]
|
||||
cfg_item1 = abcd
|
||||
@@ -389,13 +392,12 @@ EXPECT_VAL=0
|
||||
check_result "$VAL" "$EXPECT_VAL"
|
||||
set -e
|
||||
|
||||
echo -n "merge_config_group test10 not directory: "
|
||||
echo -n "merge_config_group test10 create directory: "
|
||||
set +e
|
||||
# function is expected to fail and exit, running it
|
||||
# in a subprocess to let this script proceed
|
||||
(merge_config_group test.conf test10)
|
||||
STACK_USER=$(id -u -n)
|
||||
merge_config_group test.conf test10
|
||||
VAL=$?
|
||||
EXPECT_VAL=255
|
||||
EXPECT_VAL=0
|
||||
check_result "$VAL" "$EXPECT_VAL"
|
||||
set -e
|
||||
|
||||
@@ -414,9 +416,21 @@ random = config
|
||||
non = sense'
|
||||
check_result "$VAL" "$EXPECT_VAL"
|
||||
|
||||
echo -n "merge_config_group test12 directory as file: "
|
||||
set +e
|
||||
# function is expected to fail and exit, running it
|
||||
# in a subprocess to let this script proceed
|
||||
(merge_config_group test.conf test12)
|
||||
VAL=$?
|
||||
EXPECT_VAL=255
|
||||
check_result "$VAL" "$EXPECT_VAL"
|
||||
set -e
|
||||
|
||||
|
||||
rm -f test.conf test1c.conf test2a.conf \
|
||||
test-space.conf test-equals.conf test-strip.conf \
|
||||
test-colon.conf test-env.conf test-multiline.conf \
|
||||
test-multi-sections.conf test-same.conf
|
||||
rm -rf test-etc
|
||||
rm -rf does-not-exist-dir
|
||||
|
||||
|
||||
Reference in New Issue
Block a user