File 0139-dracut.sh-check-for-logfile-logfile-option-and-creat.patch of Package dracut.892

From 449f9a748229f78844861194187ee36a4cccd7f2 Mon Sep 17 00:00:00 2001
From: jloeser <jloeser@suse.de>
Date: Mon, 18 Aug 2014 16:19:54 +0200
Subject: dracut.sh: 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
---
 dracut.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dracut.sh b/dracut.sh
index 92b30bb..ffe4989 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -803,6 +803,12 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
 # eliminate IFS hackery when messing with fw_dir
 fw_dir=${fw_dir//:/ }
 
+if [[ ! -f $logfile ]];then
+    if [[ ! `touch $logfile > /dev/null 2>&1` ]];then
+        printf "%s\n" "dracut: touch $logfile failed. Couldn't create logfile."
+    fi
+fi
+
 # handle compression options.
 [[ $compress ]] || compress="gzip"
 case $compress in
-- 
1.8.4.5