if [ -z "$fileloglvl" ]; then
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
elif (( $fileloglvl > 0 )); then
- __oldumask=$(umask)
- umask 0377
- ! [ -e "$logfile" ] && >"$logfile"
- umask $__oldumask
- if [ -w "$logfile" -a -f "$logfile" ]; then
+ if [[ $logfile ]]; then
+ __oldumask=$(umask)
+ umask 0377
+ ! [ -e "$logfile" ] && >"$logfile"
+ umask $__oldumask
+ if [ -w "$logfile" -a -f "$logfile" ]; then
# Mark new run in the log file
- echo >>"$logfile"
- if command -v date >/dev/null; then
- echo "=== $(date) ===" >>"$logfile"
+ echo >>"$logfile"
+ if command -v date >/dev/null; then
+ echo "=== $(date) ===" >>"$logfile"
+ else
+ echo "===============================================" >>"$logfile"
+ fi
+ echo >>"$logfile"
else
- echo "===============================================" >>"$logfile"
- fi
- echo >>"$logfile"
- else
# We cannot log to file, so turn this facility off.
- fileloglvl=0
- ret=1
- errmsg="'$logfile' is not a writable file"
+ fileloglvl=0
+ ret=1
+ errmsg="'$logfile' is not a writable file"
+ fi
+ fi
+ if type -P systemd-cat &>/dev/null && (( $UID == 0 )) ; then
+ readonly _dlogdir="$(mktemp --tmpdir="$TMPDIR/" -d -t dracut-log.XXXXXX)"
+ readonly _systemdcatfile="$_dlogdir/systemd-cat"
+ mkfifo "$_systemdcatfile"
+ readonly _dlogfd=15
+ systemd-cat -t 'dracut' <"$_systemdcatfile" &
+ exec 15>"$_systemdcatfile"
fi
fi
_do_dlog() {
local lvl="$1"; shift
local lvlc=$(_lvl2char "$lvl") || return 0
- local msg="$lvlc: $*"
+ local msg="$*"
+ local lmsg="$lvlc: $*"
(( $lvl <= $stdloglvl )) && echo "$msg" >&2
if (( $lvl <= $sysloglvl )); then
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) "$msg"
fi
+
if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
- echo "$msg" >>"$logfile"
+ echo "$lmsg" >>"$logfile"
+ fi
+
+ if (( $lvl <= $fileloglvl )) && [[ "$_dlogfd" ]]; then
+ echo "<$(_dlvl2syslvl $lvl)>$msg" >&$_dlogfd
fi
+
(( $lvl <= $kmsgloglvl )) && \
echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
}
i18n_default_font="latarcyrheb-sun16"
omit_drivers+=' .*/fs/ocfs/.* i2o_scsi'
stdloglvl=3
-logfile=/var/log/dracut.log
-fileloglvl=6
+fileloglvl=5
install_items+=" vi /etc/virc ps grep cat rm "
prefix="/"
systemdutildir=/usr/lib/systemd
}
fi
# clean up after ourselves no matter how we die.
-trap 'ret=$?;[[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; exit $ret; };' EXIT
+trap '
+ ret=$?;
+ [[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";
+ [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
+ [[ $keep ]] && echo "Not removing $microcode_dir." >&2 || { [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; };
+ [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
+ exit $ret;
+ ' EXIT
+
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
dracut_args[$i]="\"${dracut_args[$i]}\""
#" keep vim happy
done
-ddebug "Executing: $0 ${dracut_args[@]}"
+dinfo "Executing: $0 ${dracut_args[@]}"
[[ $do_list = yes ]] && {
for mod in $dracutbasedir/modules.d/*; do
fi
fi
-if (( maxloglvl >= 5 )); then
- ddebug "Listing sizes of included files:"
- du -c "$initdir" | sort -n | ddebug
-fi
-
PRELINK_BIN="$(command -v prelink)"
if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then
done
(cd "$microcode_dir/d"; find . | cpio -o -H newc --quiet >../ucode.cpio)
fi
+
rm -f -- "$outfile"
dinfo "*** Creating image file ***"
if [[ $early_microcode = yes ]]; then
mv -- "$outfile.$$" "$outfile"
dinfo "*** Creating image file done ***"
-dinfo "Wrote $outfile:"
-dinfo "$(ls -l "$outfile")"
+if (( maxloglvl >= 5 )); then
+ lsinitrd "$outfile"| ddebug
+fi
exit 0
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%endif
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
-install -m 0644 dracut.logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/dracut_log
-
# create compat symlink
mkdir -p $RPM_BUILD_ROOT/sbin
ln -s /usr/bin/dracut $RPM_BUILD_ROOT/sbin/dracut
%{dracutlibdir}/modules.d/99fs-lib
%{dracutlibdir}/modules.d/99img-lib
%{dracutlibdir}/modules.d/99shutdown
-%config(noreplace) %{_sysconfdir}/logrotate.d/dracut_log
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
%dir %{_sharedstatedir}/initramfs
%if %{defined _unitdir}