5 if [ -n "$NEWROOT" ]; then
6 [ -d $NEWROOT ] || mkdir
-p -m 0755 $NEWROOT
9 if ! [ -d /run
/initramfs
]; then
10 mkdir
-p -m 0755 /run
/initramfs
/log
11 ln -sfn /run
/initramfs
/log
/var
/log
14 [ -d /run
/lock
] || mkdir
-p -m 0755 /run
/lock
15 [ -d /run
/log
] || mkdir
-p -m 0755 /run
/log
22 [ "$RD_DEBUG" = "yes" ] && set -x
25 # returns OK if $1 contains literal string $2 (and isn't empty)
27 [ "${1##*"$2"*}" != "$1" ]
30 # returns OK if $1 matches (completely) glob pattern $2
31 # An empty $1 will not be considered matched, even if $2 is * which technically
32 # matches; as it would match anything, it's not an interesting case.
34 [ -n "$1" -a -z "${1##$2}" ]
37 # returns OK if $1 contains (anywhere) a match of glob pattern $2
38 # An empty $1 will not be considered matched, even if $2 is * which technically
39 # matches; as it would match anything, it's not an interesting case.
41 [ -n "$1" -a -z "${1##*$2*}" ]
44 # returns OK if $1 contains literal string $2 at the beginning, and isn't empty
46 [ "${1#"$2"*}" != "$1" ]
49 # returns OK if $1 contains literal string $2 at the end, and isn't empty
51 [ "${1%*"$2"}" != "$1" ]
56 var
="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
57 var
="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
61 if [ -z "$DRACUT_SYSTEMD" ]; then
65 echo "<28>dracut Warning: $*" > /dev
/kmsg
66 echo "dracut Warning: $*" >&2
71 echo "<30>dracut: $*" > /dev
/kmsg
72 [ "$DRACUT_QUIET" != "yes" ] && \
79 echo "Warning: $*" >&2
89 while read line ||
[ -n "$line" ]; do
95 while read line ||
[ -n "$line" ]; do
100 # replaces all occurrences of 'search' in 'str' with 'replacement'
102 # str_replace str search replacement
105 # str_replace ' one two three ' ' ' '_'
107 local in="$1"; local s
="$2"; local r
="$3"
110 while strstr
"${in}" "$s"; do
112 out
="${out}${chop}$r"
118 killall_proc_mountpoint
() {
122 for _pid
in /proc
/*; do
127 [ -e "/proc/$_pid/exe" ] ||
continue
128 [ -e "/proc/$_pid/root" ] ||
continue
129 if strstr
"$(ls -l -- "/proc
/$_pid" "/proc
/$_pid/fd
" 2>/dev/null)" "$1" ; then
145 if [ -e /etc
/cmdline
]; then
146 while read -r _line ||
[ -n "$_line" ]; do
147 CMDLINE_ETC
="$CMDLINE_ETC $_line";
150 for _i
in /etc
/cmdline.d
/*.conf
; do
151 [ -e "$_i" ] ||
continue
152 while read -r _line ||
[ -n "$_line" ]; do
153 CMDLINE_ETC_D
="$CMDLINE_ETC_D $_line";
156 if [ -e /proc
/cmdline
]; then
157 while read -r _line ||
[ -n "$_line" ]; do
158 CMDLINE_PROC
="$CMDLINE_PROC $_line"
161 CMDLINE
="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE_PROC"
162 printf "%s" "$CMDLINE"
166 local _o _val _doecho
170 CMDLINE
=$
(getcmdline
)
172 for _o
in $CMDLINE; do
173 if [ "${_o%%=*}" = "${1%%=*}" ]; then
174 if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then
175 # if $1 has a "=<value>", we want the exact match
176 if [ "$_o" = "$1" ]; then
183 if [ "${_o#*=}" = "$_o" ]; then
184 # if cmdline argument has no "=<value>", we assume "=1"
194 if [ -n "$_val" ]; then
195 [ "x$_doecho" != "x" ] && echo "$_val";
203 local _deprecated _newoption
204 while [ $# -gt 0 ]; do
206 -d) _deprecated
=1; shift;;
207 -y) if _dogetarg
$2 >/dev
/null
; then
208 if [ "$_deprecated" = "1" ]; then
209 [ -n "$_newoption" ] && warn
"Kernel command line option '$2' is deprecated, use '$_newoption' instead." || warn
"Option '$2' is deprecated."
217 -n) if _dogetarg
$2 >/dev
/null
; then
219 if [ "$_deprecated" = "1" ]; then
220 [ -n "$_newoption" ] && warn
"Kernel command line option '$2' is deprecated, use '$_newoption=0' instead." || warn
"Option '$2' is deprecated."
227 *) if [ -z "$_newoption" ]; then
230 if _dogetarg
$1; then
231 if [ "$_deprecated" = "1" ]; then
232 [ -n "$_newoption" ] && warn
"Kernel command line option '$1' is deprecated, use '$_newoption' instead." || warn
"Option '$1' is deprecated."
245 # getargbool <defaultval> <args...>
246 # False if "getarg <args...>" returns "0", "no", or "off".
247 # True if getarg returns any other non-empty string.
248 # If not found, assumes <defaultval> - usually 0 for false, 1 for true.
249 # example: getargbool 0 rd.info
250 # true: rd.info, rd.info=1, rd.info=xxx
251 # false: rd.info=0, rd.info=off, rd.info not present (default val is 0)
258 [ $?
-ne 0 -a -z "$_b" ] && _b
="$_default"
259 if [ -n "$_b" ]; then
260 [ $_b = "0" ] && return 1
261 [ $_b = "no" ] && return 1
262 [ $_b = "off" ] && return 1
269 *[!0-9]*|
"") return 1;;
275 # getargnum <defaultval> <minval> <maxval> <arg>
276 # Will echo the arg if it's in range [minval - maxval].
277 # If it's not set or it's not valid, will set it <defaultval>.
278 # Note all values are required to be >= 0 here.
279 # <defaultval> should be with [minval -maxval].
283 local _default _min _max
288 [ $?
-ne 0 -a -z "$_b" ] && _b
=$_default
289 if [ -n "$_b" ]; then
290 isdigit
"$_b" && _b
=$
(($_b)) && \
291 [ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return
301 CMDLINE
=$
(getcmdline
)
304 for _o
in $CMDLINE; do
305 if [ "$_o" = "$_key" ]; then
307 elif [ "${_o%%=*}" = "${_key%=}" ]; then
308 [ -n "${_o%%=*}" ] && set -- "$@" "${_o#*=}";
312 if [ -n "$_found" ]; then
313 [ $# -gt 0 ] && printf '%s' "$*"
321 local _val _i _args _gfound _deprecated
328 if [ "$_i" = "-d" ]; then
332 _val
="$(_dogetargs $_i)"
333 if [ $?
-eq 0 ]; then
334 if [ "$_deprecated" = "1" ]; then
335 [ -n "$_newoption" ] && warn
"Option '$_i' is deprecated, use '$_newoption' instead." || warn
"Option $_i is deprecated!"
339 [ -n "$_val" ] && set -- "$@" "$_val"
342 if [ -n "$_gfound" ]; then
343 if [ $# -gt 0 ]; then
354 # Prints value of given option. If option is a flag and it's present,
355 # it just returns 0. Otherwise 1 is returned.
356 # $1 = options separated by commas
357 # $2 = option we are interested in
360 # $1 = cipher=aes-cbc-essiv:sha256,hash=sha256,verify
365 local line
=",$1,"; local opt
="$2"; local tmp
369 tmp
="${line#*,${opt}=}"
373 *,${opt},*) return 0;;
378 # Splits given string 'str' with separator 'sep' into variables 'var1', 'var2',
379 # 'varN'. If number of fields is less than number of variables, remaining are
380 # not set. If number of fields is greater than number of variables, the last
381 # variable takes remaining fields. In short - it acts similary to 'read'.
383 # splitsep sep str var1 var2 varN
386 # splitsep ':' 'foo:bar:baz' v1 v2
388 # v1='foo', v2='bar:baz'
390 # TODO: ':' inside fields.
393 local sep
="$1"; local str
="$2"; shift 2
396 while [ -n "$str" -a "$#" -gt 1 ]; do
403 [ -n "$str" -a -n "$1" ] && eval "$1='$str'"
409 [ -f /usr
/lib
/initrd-release
] ||
return
410 if [ -z "$RD_DEBUG" ]; then
411 if [ -e /proc
/cmdline
]; then
413 if getargbool
0 rd.debug
-d -y rdinitdebug
-d -y rdnetdebug
; then
416 export PS4
='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
430 [ "$_dir" ] && [ -d "/$_dir" ] ||
return
431 for f
in "/$_dir"/*.sh
; do [ -e "$f" ] && .
"$f" "$@"; done
434 hookdir
=/lib
/dracut
/hooks
440 source_all
"/lib/dracut/hooks/$_dir" "$@"
445 for f
in $hookdir/initqueue
/finished
/*.sh
; do
446 [ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0
447 { [ -e "$f" ] && ( .
"$f" ) ; } ||
return 1
454 [ "$1" ] && [ -d "/$1" ] ||
return
455 for f
in "/$1"/*.conf
; do [ -e "$f" ] && .
"$f"; done
460 echo "<24>dracut: FATAL: $*";
461 echo "<24>dracut: Refusing to continue";
465 echo "warn dracut: FATAL: \"$*\"";
466 echo "warn dracut: Refusing to continue";
467 } >> $hookdir/emergency
/01-die.sh
468 [ -d /run
/initramfs
] || mkdir
-p -- /run
/initramfs
470 > /run
/initramfs
/.die
472 if getargbool
0 "rd.shell"; then
475 source_hook
"shutdown-emergency"
478 if [ -n "$DRACUT_SYSTEMD" ]; then
479 systemctl
--no-block --force halt
486 if [ -z "$DRACUT_QUIET" ]; then
488 getargbool
0 rd.info
-d -y rdinfo
&& DRACUT_QUIET
="no"
489 getargbool
0 rd.debug
-d -y rdinitdebug
&& DRACUT_QUIET
="no"
490 getarg quiet || DRACUT_QUIET
="yes"
491 a
=$
(getarg loglevel
=)
492 [ -n "$a" ] && [ $a -ge 28 ] && DRACUT_QUIET
="yes"
499 # Count the number of times the character $ch occurs in $str
500 # Return 0 if the count matches the expected number, 1 otherwise
506 while [ "${str#*$ch}" != "${str}" ]; do
508 count
=$
(( $count + 1 ))
511 [ $count -eq $expected ]
520 [ -z "$file" ] && return 1;
521 [ -z "$str" ] && return 1;
523 while read dummy check restofline ||
[ -n "$check" ]; do
524 if [ "$check" = "$str" ]; then
534 [ -z "$UDEVVERSION" ] && export UDEVVERSION
=$
(udevadm
--version)
536 if [ $UDEVVERSION -ge 143 ]; then
537 udevadm settle
--exit-if-exists=$hookdir/initqueue
/work
$settle_exit_if_exists
539 udevadm settle
--timeout=30
544 [ -z "$UDEVVERSION" ] && export UDEVVERSION
=$
(udevadm
--version)
546 if [ $UDEVVERSION -ge 143 ]; then
547 for i
in "$@"; do udevadm control
--property=$i; done
549 for i
in "$@"; do udevadm control
--env=$i; done
554 local dev mnt etc wanted_dev
555 wanted_dev
="$(readlink -e -q $1)"
556 while read dev mnt etc ||
[ -n "$dev" ]; do
557 [ "$dev" = "$wanted_dev" ] && echo "$dev" && return 0
562 # usage: ismounted <mountpoint>
563 # usage: ismounted /dev/<device>
564 if command -v findmnt
>/dev
/null
; then
566 findmnt
"$1" > /dev
/null
2>&1
571 find_mount
"$1" > /dev
/null
&& return 0
575 while read a m a ||
[ -n "$m" ]; do
576 [ "$m" = "$1" ] && return 0
582 # root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
583 # root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
590 # check if we have a server
591 if strstr
"$arg" ':/' ; then
599 options
="${arg##$path}"
601 options
="${options##:}"
603 options
="${options%%:}"
605 # Does it really start with '/'?
606 [ -n "${path%%/*}" ] && path
="error";
608 #Fix kernel legacy style separating path and options with ','
609 if [ "$path" != "${path#*,}" ] ; then
615 # Create udev rule match for a device with its device name, or the udev property
616 # ID_FS_UUID or ID_FS_LABEL
619 # udevmatch LABEL=boot
621 # ENV{ID_FS_LABEL}="boot"
626 UUID
=????????
-????
-????
-????
-????????????|LABEL
=*|PARTLABEL
=*|PARTUUID
=????????
-????
-????
-????
-????????????
)
627 printf 'ENV{ID_FS_%s}=="%s"' "${1%%=*}" "${1#*=}"
630 printf 'ENV{ID_FS_UUID}=="%s*"' "${1#*=}"
633 printf 'ENV{ID_FS_PARTUUID}=="%s*"' "${1#*=}"
635 /dev
/?
*) printf -- 'KERNEL=="%s"' "${1#/dev/}" ;;
640 # Prints unique path for potential file inside specified directory. It consists
641 # of specified directory, prefix and number at the end which is incremented
642 # until non-existing file is found.
653 local dir
="$1"; local prefix
="$2"
656 [ -d "${dir}" ] ||
return 1
658 while [ -e "${dir}/${prefix}$i" ]; do
659 i
=$
(($i+1)) ||
return 1
662 echo "${dir}/${prefix}$i"
665 # Creates unique directory and prints its path. It's using funiq to generate
668 # mkuniqdir subdir new_dir_name
670 local dir
="$1"; local prefix
="$2"
671 local retdir
; local retdir_new
673 [ -d "${dir}" ] || mkdir
-m 0755 -p "${dir}" ||
return 1
675 retdir
=$
(funiq
"${dir}" "${prefix}") ||
return 1
676 until mkdir
-m 0755 "${retdir}" 2>/dev
/null
; do
677 retdir_new
=$
(funiq
"${dir}" "${prefix}") ||
return 1
678 [ "$retdir_new" = "$retdir" ] && return 1
685 # Copy the contents of SRC into DEST, merging the contents of existing
686 # directories (kinda like rsync, or cpio -p).
687 # Creates DEST if it doesn't exist. Overwrites files with the same names.
691 local src
="$1" dest
="$2"
692 mkdir
-p "$dest"; dest
=$
(readlink
-e -q "$dest")
693 ( cd "$src"; cp -af .
-t "$dest" )
696 # Evaluates command for UUIDs either given as arguments for this function or all
697 # listed in /dev/disk/by-uuid. UUIDs doesn't have to be fully specified. If
698 # beginning is given it is expanded to all matching UUIDs. To pass full UUID to
699 # your command use '$___' as a place holder. Remember to escape '$'!
701 # foreach_uuid_until [ -p prefix ] command UUIDs
703 # prefix - string to put just before $___
704 # command - command to be evaluated
705 # UUIDs - list of UUIDs separated by space
707 # The function returns after *first successful evaluation* of the given command
708 # with status 0. If evaluation fails for every UUID function returns with
712 # foreach_uuid_until "mount -U \$___ /mnt; echo OK; umount /mnt" \
713 # "01234 f512 a235567f-12a3-c123-a1b1-01234567abcb"
714 foreach_uuid_until
() (
717 [ "$1" = -p ] && local prefix
="$2" && shift 2
718 local cmd
="$1"; shift; local uuids_list
="$*"
719 local uuid
; local full_uuid
; local ___
721 [ -n "${cmd}" ] ||
return 1
723 for uuid
in ${uuids_list:-*}; do
724 for full_uuid
in ${uuid}*; do
725 [ -e "${full_uuid}" ] ||
continue
726 ___
="${prefix}${full_uuid}"
727 eval ${cmd} && return 0
734 # Get kernel name for given device. Device may be the name too (then the same
735 # is returned), a symlink (full path), UUID (prefixed with "UUID=") or label
736 # (prefixed with "LABEL="). If just a beginning of the UUID is specified or
737 # even an empty, function prints all device names which UUIDs match - every in
740 # NOTICE: The name starts with "/dev/".
749 local dev
="$1"; local d
; local names
753 dev
="$(foreach_uuid_until '! blkid -U $___' "${dev#UUID=}")" \
755 [ -z "$dev" ] && return 255
757 LABEL
=*) dev
="$(blkid -L "${dev#LABEL=}")" ||
return 255 ;;
764 $(readlink -e -q "$d")" ||
return 255
775 [ -d "$1" ] ||
return 1
777 for _i
in "$1"/usr
/lib
*/ld-
*.so
"$1"/lib
*/ld-
*.so
; do
778 [ -e "$_i" ] && return 0
781 for _i
in proc sys dev
; do
782 [ -e "$1"/$_i ] ||
return 1
789 local _hookname _unique _name _job _exe
790 while [ $# -gt 0 ]; do
793 _hookname
="/$2";shift;;
804 if [ -z "$_unique" ]; then
814 [ -x "$_exe" ] || _exe
=$
(command -v $_exe)
816 if [ -n "$onetime" ]; then
818 echo '[ -e "$_job" ] && rm -f -- "$_job"'
820 } > "/tmp/$$-${_job}.sh"
822 echo "$_exe $@" > "/tmp/$$-${_job}.sh"
825 mv -f "/tmp/$$-${_job}.sh" "$hookdir/${_hookname}/${_job}.sh"
828 # inst_mount_hook <mountpoint> <prio> <name> <script>
830 # Install a mount hook with priority <prio>,
831 # which executes <script> as soon as <mountpoint> is mounted.
833 local _prio
="$2" _jobname
="$3" _script
="$4"
834 local _hookname
="mount-$(str_replace "$1" '/' '\\x2f')"
835 [ -d "$hookdir/${_hookname}" ] || mkdir
-p "$hookdir/${_hookname}"
836 inst_hook
--hook "$_hookname" --unique --name "${_prio}-${_jobname}" "$_script"
839 # add_mount_point <dev> <mountpoint> <filesystem> <fsopts>
841 # Mount <dev> on <mountpoint> with <filesystem> and <fsopts>
842 # and call any mount hooks, as soon, as it is mounted
844 local _dev
="$1" _mp
="$2" _fs
="$3" _fsopts
="$4"
845 local _hookname
="mount-$(str_replace "$2" '/' '\\x2f')"
846 local _devname
="dev-$(str_replace "$1" '/' '\\x2f')"
847 echo "$_dev $_mp $_fs $_fsopts 0 0" >> /etc
/fstab
849 exec 7>/etc
/udev
/rules.d
/99-mount-${_devname}.rules
850 echo 'SUBSYSTEM!="block", GOTO="mount_end"' >&7
851 echo 'ACTION!="add|change", GOTO="mount_end"' >&7
852 if [ -n "$_dev" ]; then
853 udevmatch
"$_dev" >&7 ||
{
854 warn
"add_mount_point dev=$_dev incorrect!"
861 printf -- 'RUN+="%s --unique --onetime ' $
(command -v initqueue
)
862 printf -- '--name mount-%%k '
863 printf -- '%s %s"\n' "$(command -v mount_hook)" "${_mp}"
865 echo 'LABEL="mount_end"' >&7
869 # wait_for_mount <mountpoint>
871 # Installs a initqueue-finished script,
872 # which will cause the main loop only to exit,
873 # if <mountpoint> is mounted.
877 _name
="$(str_replace "$1" '/' '\\x2f')"
878 printf '. /lib/dracut-lib.sh\nismounted "%s"\n' $1 \
879 >> "$hookdir/initqueue/finished/ismounted-${_name}.sh"
881 printf 'ismounted "%s" || ' $1
882 printf 'warn "\"%s\" is not mounted"\n' $1
883 } >> "$hookdir/emergency/90-${_name}.sh"
886 # get a systemd-compatible unit name from a path
887 # (mimicks unit_name_from_path_instance())
892 if command -v systemd-escape
>/dev
/null
; then
893 systemd-escape
-p -- "$dev"
897 if [ "$dev" = "/" -o -z "$dev" ]; then
904 dev
="$(str_replace "$dev" '\' '\x5c')"
905 dev
="$(str_replace "$dev" '-' '\x2d')"
906 if [ "${dev##.}" != "$dev" ]; then
909 dev
="$(str_replace "$dev" '/' '-')"
911 printf -- "%s" "$dev"
914 # set_systemd_timeout_for_dev <dev>
915 # Set 'rd.timeout' as the systemd timeout for <dev>
917 set_systemd_timeout_for_dev
()
924 if [ "$1" = "-n" ]; then
929 _timeout
=$
(getarg rd.timeout
)
930 _timeout
=${_timeout:-0}
932 if [ -n "$DRACUT_SYSTEMD" ]; then
933 _name
=$
(dev_unit_name
"$1")
934 if ! [ -L ${PREFIX}/etc
/systemd
/system
/initrd.target.wants
/${_name}.device
]; then
935 [ -d ${PREFIX}/etc
/systemd
/system
/initrd.target.wants
] || mkdir
-p ${PREFIX}/etc
/systemd
/system
/initrd.target.wants
936 ln -s ..
/${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device
937 type mark_hostonly
>/dev
/null
2>&1 && mark_hostonly
/etc
/systemd
/system
/initrd.target.wants
/${_name}.device
941 if ! [ -f ${PREFIX}/etc
/systemd
/system
/${_name}.device.d
/timeout.conf
]; then
942 mkdir
-p ${PREFIX}/etc
/systemd
/system
/${_name}.device.d
945 echo "JobTimeoutSec=$_timeout"
946 echo "JobRunningTimeoutSec=$_timeout"
947 } > ${PREFIX}/etc
/systemd
/system
/${_name}.device.d
/timeout.conf
948 type mark_hostonly
>/dev
/null
2>&1 && mark_hostonly
/etc
/systemd
/system
/${_name}.device.d
/timeout.conf
952 if [ -z "$PREFIX" ] && [ "$_needreload" = 1 ] && [ -z "$_noreload" ]; then
953 /sbin
/initqueue
--onetime --unique --name daemon-reload systemctl daemon-reload
959 # Installs a initqueue-finished script,
960 # which will cause the main loop only to exit,
961 # if the device <dev> is recognized by the system.
967 if [ "$1" = "-n" ]; then
972 _name
="$(str_replace "$1" '/' '\x2f')"
974 type mark_hostonly
>/dev
/null
2>&1 && mark_hostonly
"$hookdir/initqueue/finished/devexists-${_name}.sh"
976 [ -e "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
978 printf '[ -e "%s" ]\n' $1 \
979 >> "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh"
981 printf '[ -e "%s" ] || ' $1
982 printf 'warn "\"%s\" does not exist"\n' $1
983 } >> "${PREFIX}$hookdir/emergency/80-${_name}.sh"
985 set_systemd_timeout_for_dev
$_noreload $1
988 cancel_wait_for_dev
()
991 _name
="$(str_replace "$1" '/' '\x2f')"
992 rm -f -- "$hookdir/initqueue/finished/devexists-${_name}.sh"
993 rm -f -- "$hookdir/emergency/80-${_name}.sh"
994 if [ -n "$DRACUT_SYSTEMD" ]; then
995 _name
=$
(dev_unit_name
"$1")
996 rm -f -- ${PREFIX}/etc
/systemd
/system
/initrd.target.wants
/${_name}.device
997 rm -f -- ${PREFIX}/etc
/systemd
/system
/${_name}.device.d
/timeout.conf
998 /sbin
/initqueue
--onetime --unique --name daemon-reload systemctl daemon-reload
1004 local _exe
="$(command -v $1)"
1007 [ -x "$_exe" ] ||
return 1
1008 for _i
in /proc
/[0-9]*; do
1009 [ "$_i" = "/proc/1" ] && continue
1010 if [ -e "$_i"/_exe
] && [ "$_i/_exe" -ef "$_exe" ] ; then
1011 kill $_sig ${_i##*/}
1018 >/run
/initramfs
/.need_shutdown
1023 [ "$RD_DEBUG" = "yes" ] ||
return
1024 [ -e /run
/initramfs
/loginit.pipe
] ||
return
1026 echo "DRACUT_LOG_END"
1027 exec 0<>/dev
/console
1<>/dev
/console
2<>/dev
/console
1030 while [ $i -lt 10 ]; do
1031 if [ ! -e /run
/initramfs
/loginit.pipe
]; then
1033 [ -z "$j" ] && break
1034 [ -z "${j##*Running*}" ] ||
break
1040 if [ $i -eq 10 ]; then
1041 kill %1 >/dev
/null
2>&1
1042 kill $
(while read line ||
[ -n "$line" ];do echo $line;done</run
/initramfs
/loginit.pid
)
1046 rm -f -- /run
/initramfs
/loginit.pipe
/run
/initramfs
/loginit.pid
1049 # pidof version for root
1050 if ! command -v pidof
>/dev
/null
2>/dev
/null
; then
1059 if [ -z "$_cmd" ]; then
1063 _exe
=$
(command -v "$1")
1064 for i
in /proc
/*/exe
; do
1065 [ -e "$i" ] ||
continue
1066 if [ -n "$_exe" ]; then
1067 [ "$i" -ef "$_exe" ] ||
continue
1069 _rl
=$
(readlink
-f "$i");
1070 [ "${_rl%/$_cmd}" != "$_rl" ] ||
continue
1084 if [ -n "$DRACUT_SYSTEMD" ]; then
1086 echo "PS1=\"$_name:\\\${PWD}# \"" >/etc
/profile
1087 systemctl start dracut-emergency.service
1088 rm -f -- /etc
/profile
1089 rm -f -- /.console_lock
1095 echo 'You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot'
1096 echo 'after mounting them and attach it to a bug report.'
1097 if ! RD_DEBUG
= getargbool
0 rd.debug
-d -y rdinitdebug
-d -y rdnetdebug
; then
1099 echo 'To get more debug information in the report,'
1100 echo 'reboot with "rd.debug" added to the kernel command line.'
1103 echo 'Dropping to debug shell.'
1105 export PS1
="$_name:\${PWD}# "
1106 [ -e /.profile
] ||
>/.profile
1108 _ctty
="$(RD_DEBUG= getarg rd.ctty=)" && _ctty
="/dev/${_ctty##*/}"
1109 if [ -z "$_ctty" ]; then
1111 while [ -f /sys
/class
/tty
/$_ctty/active
]; do
1112 _ctty
=$
(cat /sys
/class
/tty
/$_ctty/active
)
1113 _ctty
=${_ctty##* } # last one in the list
1117 [ -c "$_ctty" ] || _ctty
=/dev
/tty1
1118 case "$(/usr/bin/setsid --help 2>&1)" in *--ctty*) CTTY
="--ctty";; esac
1119 setsid
$CTTY /bin
/sh
-i -l 0<>$_ctty 1<>$_ctty 2<>$_ctty
1127 local _rdshell_name
="dracut" action
="Boot" hook
="emergency"
1128 local _emergency_action
1130 if [ "$1" = "-n" ]; then
1133 elif [ "$1" = "--shutdown" ]; then
1134 _rdshell_name
=$2; action
="Shutdown"; hook
="shutdown-emergency"
1135 if type plymouth
>/dev
/null
2>&1; then
1136 plymouth
--hide-splash
1137 elif [ -x /oldroot
/bin
/plymouth
]; then
1138 /oldroot
/bin
/plymouth
--hide-splash
1147 _emergency_action
=$
(getarg rd.emergency
)
1148 [ -z "$_emergency_action" ] \
1149 && [ -e /run
/initramfs
/.die
] \
1150 && _emergency_action
=halt
1152 if getargbool
1 rd.shell
-d -y rdshell || getarg rd.
break -d rdbreak
; then
1153 _emergency_shell
$_rdshell_name
1156 warn
"$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
1157 [ -z "$_emergency_action" ] && _emergency_action
=halt
1160 case "$_emergency_action" in
1164 poweroff ||
exit 1;;
1170 # Retain the values of these variables but ensure that they are unexported
1171 # This is a POSIX-compliant equivalent of bash's "export -n"
1179 [ -n "$val" ] && eval $var=\"$val\"
1183 # returns OK if list1 contains all elements of list2, i.e. checks if list2 is a
1184 # sublist of list1. An order and a duplication doesn't matter.
1189 # $4 = ignore values, separated by $1
1192 local _list
="${_sep}${2}${_sep}"
1194 [ -n "$4" ] && local _iglist
="${_sep}${4}${_sep}"
1198 [ "$_list" = "$_sublist" ] && return 0
1200 for _v
in $_sublist; do
1201 if [ -n "$_v" ] && ! ( [ -n "$_iglist" ] && strstr
"$_iglist" "$_v" )
1203 strstr
"$_list" "$_v" ||
return 1
1210 # returns OK if both lists contain the same values. An order and a duplication
1216 # $4 = ignore values, separated by $1
1218 listlist
"$1" "$2" "$3" "$4" && listlist
"$1" "$3" "$2" "$4"
1222 if [ -z "$DEBUG_MEM_LEVEL" ]; then
1223 export DEBUG_MEM_LEVEL
=$
(getargnum
0 0 4 rd.memdebug
)
1231 # tracekomem based on kernel trace needs cleanup after use.
1232 if [ "$DEBUG_MEM_LEVEL" -eq 4 ]; then
1233 tracekomem
--cleanup
1237 # parameters: msg [trace_level:trace]...
1243 if [ -n "$DEBUG_MEM_LEVEL" ] && [ "$DEBUG_MEM_LEVEL" -gt 0 ]; then
1244 make_trace show_memstats
$DEBUG_MEM_LEVEL "[debug_mem]" "$msg" "$@" >&2
1248 # parameters: func log_level prefix msg [trace_level:trace]...
1251 local func log_level prefix msg msg_printed
1252 local trace trace_level trace_in_higher_levels insert_trace
1266 if [ -z "$log_level" ]; then
1273 while [ $# -gt 0 ]; do
1275 trace_level
=${trace%%+}
1276 [ "$trace" != "$trace_level" ] && trace_in_higher_levels
="yes"
1279 if [ -z "$trace_level" ]; then
1284 if [ -n "$trace_in_higher_levels" ]; then
1285 if [ "$log_level" -ge "$trace_level" ]; then
1289 if [ "$log_level" -eq "$trace_level" ]; then
1294 if [ $insert_trace -eq 1 ]; then
1295 if [ $msg_printed -eq 0 ]; then
1310 cat /proc
/meminfo |
grep -e "^MemFree" -e "^Cached" -e "^Slab"
1327 remove_hostonly_files
() {
1328 rm -fr /etc
/cmdline
/etc
/cmdline.d
/*.conf
"$hookdir/initqueue/finished"
1329 if [ -f /lib
/dracut
/hostonly-files
]; then
1330 while read -r line ||
[ -n "$line" ]; do
1331 [ -e "$line" ] ||
[ -h "$line" ] ||
continue
1333 done < /lib
/dracut
/hostonly-files