Blame 0053-Check-for-logfile-logfile-option-and-create-it-if-ne.patch

Harald Hoyer b94732
From 3838dc47c3f15128f171bfbd0eaf2e3e8641e4e8 Mon Sep 17 00:00:00 2001
Harald Hoyer b94732
From: jloeser <jloeser@suse.de>
Harald Hoyer b94732
Date: Thu, 11 Dec 2014 15:46:14 +0100
Harald Hoyer b94732
Subject: [PATCH] Check for logfile (--logfile option) and create it if
Harald Hoyer b94732
 necessary
Harald Hoyer b94732
Harald Hoyer b94732
If a logfile is passed to dracut via --logfile option and doesn't
Harald Hoyer b94732
exist, dracut doesn't create it and logs nothing. Instead, dracut
Harald Hoyer b94732
should try to touch the file and print a warning if creating fails.
Harald Hoyer b94732
Harald Hoyer b94732
References: bnc#892191
Harald Hoyer b94732
Signed-off-by: Thomas Renninger <trenn@suse.de>
Harald Hoyer b94732
---
Harald Hoyer b94732
 dracut.sh | 10 ++++++++++
Harald Hoyer b94732
 1 file changed, 10 insertions(+)
Harald Hoyer b94732
Harald Hoyer b94732
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer b94732
index cda7955..79f36b6 100755
Harald Hoyer b94732
--- a/dracut.sh
Harald Hoyer b94732
+++ b/dracut.sh
Harald Hoyer b94732
@@ -816,6 +816,16 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
Harald Hoyer b94732
 # eliminate IFS hackery when messing with fw_dir
Harald Hoyer b94732
 fw_dir=${fw_dir//:/ }
Harald Hoyer b94732
 
Harald Hoyer b94732
+# check for logfile and try to create one if it doesn't exist
Harald Hoyer b94732
+if [[ -n "$logfile" ]];then
Harald Hoyer b94732
+    if [[ ! -f "$logfile" ]];then
Harald Hoyer b94732
+        touch "$logfile"
Harald Hoyer b94732
+        if [ ! $? -eq 0 ] ;then
Harald Hoyer b94732
+            printf "%s\n" "dracut: touch $logfile failed." >&2
Harald Hoyer b94732
+        fi
Harald Hoyer b94732
+    fi
Harald Hoyer b94732
+fi
Harald Hoyer b94732
+
Harald Hoyer b94732
 # handle compression options.
Harald Hoyer b94732
 [[ $compress ]] || compress="gzip"
Harald Hoyer b94732
 case $compress in