]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Check for logfile (--logfile option) and create it if necessary
authorjloeser <jloeser@suse.de>
Thu, 11 Dec 2014 14:46:14 +0000 (15:46 +0100)
committerHarald Hoyer <harald@redhat.com>
Tue, 16 Dec 2014 12:29:36 +0000 (13:29 +0100)
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>
dracut.sh

index cda79550c670b63cf776ea2fceb5fca51f7bee3b..79f36b6ea1226c87d1fa930ce544e14137b390cd 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -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