From: Thomas Renninger Subject: [PATCH 23/42] Check for logfile (--logfile option) and create it if necessary Date: Thu, 11 Dec 2014 15:46:14 +0100 Message-ID: <1418309193-11208-24-git-send-email-trenn@suse.de> References: <1418309193-11208-1-git-send-email-trenn@suse.de> Return-path: In-Reply-To: <1418309193-11208-1-git-send-email-trenn-l3A5Bk7waGM@public.gmane.org> Sender: initramfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Cc: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, trenn-l3A5Bk7waGM@public.gmane.org, jloeser From: jloeser 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 --- dracut.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dracut.sh b/dracut.sh index cda7955..79f36b6 100755 --- 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 -- 1.8.5.2