Check for logfile (--logfile option) and create it if necessary

If a logfile is passed to dracut via --logfile option and doesn't
exist, dracut doesn't create it and logs nothing. Instead, dracut
should try to touch the file and print a warning if creating fails.

References: bnc#892191
Signed-off-by: Thomas Renninger <trenn@suse.de>
master
jloeser 2014-12-11 15:46:14 +01:00 committed by Harald Hoyer
parent 5c84d51b3f
commit 3838dc47c3
1 changed files with 10 additions and 0 deletions

View File

@ -816,6 +816,16 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
# eliminate IFS hackery when messing with fw_dir
fw_dir=${fw_dir//:/ }

# check for logfile and try to create one if it doesn't exist
if [[ -n "$logfile" ]];then
if [[ ! -f "$logfile" ]];then
touch "$logfile"
if [ ! $? -eq 0 ] ;then
printf "%s\n" "dracut: touch $logfile failed." >&2
fi
fi
fi

# handle compression options.
[[ $compress ]] || compress="gzip"
case $compress in