Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../proc/self/root/lib/dracut
File: dracut-init.sh
#!/bin/bash
[0] Fix | Delete
#
[1] Fix | Delete
# functions used only by dracut and dracut modules
[2] Fix | Delete
#
[3] Fix | Delete
# Copyright 2005-2009 Red Hat, Inc. All rights reserved.
[4] Fix | Delete
#
[5] Fix | Delete
# This program is free software; you can redistribute it and/or modify
[6] Fix | Delete
# it under the terms of the GNU General Public License as published by
[7] Fix | Delete
# the Free Software Foundation; either version 2 of the License, or
[8] Fix | Delete
# (at your option) any later version.
[9] Fix | Delete
#
[10] Fix | Delete
# This program is distributed in the hope that it will be useful,
[11] Fix | Delete
# but WITHOUT ANY WARRANTY; without even the implied warranty of
[12] Fix | Delete
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[13] Fix | Delete
# GNU General Public License for more details.
[14] Fix | Delete
#
[15] Fix | Delete
# You should have received a copy of the GNU General Public License
[16] Fix | Delete
# along with this program. If not, see <http://www.gnu.org/licenses/>.
[17] Fix | Delete
#
[18] Fix | Delete
export LC_MESSAGES=C
[19] Fix | Delete
[20] Fix | Delete
if [[ "$EUID" = "0" ]]; then
[21] Fix | Delete
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
[22] Fix | Delete
else
[23] Fix | Delete
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"
[24] Fix | Delete
fi
[25] Fix | Delete
[26] Fix | Delete
# is_func <command>
[27] Fix | Delete
# Check whether $1 is a function.
[28] Fix | Delete
is_func() {
[29] Fix | Delete
[[ "$(type -t "$1")" = "function" ]]
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
if ! [[ $dracutbasedir ]]; then
[33] Fix | Delete
dracutbasedir=${BASH_SOURCE[0]%/*}
[34] Fix | Delete
[[ $dracutbasedir = dracut-functions* ]] && dracutbasedir="."
[35] Fix | Delete
[[ $dracutbasedir ]] || dracutbasedir="."
[36] Fix | Delete
dracutbasedir="$(readlink -f $dracutbasedir)"
[37] Fix | Delete
fi
[38] Fix | Delete
[39] Fix | Delete
if ! is_func dinfo >/dev/null 2>&1; then
[40] Fix | Delete
. "$dracutbasedir/dracut-logger.sh"
[41] Fix | Delete
dlog_init
[42] Fix | Delete
fi
[43] Fix | Delete
[44] Fix | Delete
if ! [[ $initdir ]]; then
[45] Fix | Delete
dfatal "initdir not set"
[46] Fix | Delete
exit 1
[47] Fix | Delete
fi
[48] Fix | Delete
[49] Fix | Delete
if ! [[ -d $initdir ]]; then
[50] Fix | Delete
mkdir -p "$initdir"
[51] Fix | Delete
fi
[52] Fix | Delete
[53] Fix | Delete
if ! [[ $kernel ]]; then
[54] Fix | Delete
kernel=$(uname -r)
[55] Fix | Delete
export kernel
[56] Fix | Delete
fi
[57] Fix | Delete
[58] Fix | Delete
srcmods="/lib/modules/$kernel/"
[59] Fix | Delete
[60] Fix | Delete
[[ $drivers_dir ]] && {
[61] Fix | Delete
if ! command -v kmod &>/dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
[62] Fix | Delete
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
[63] Fix | Delete
exit 1
[64] Fix | Delete
fi
[65] Fix | Delete
srcmods="$drivers_dir"
[66] Fix | Delete
}
[67] Fix | Delete
export srcmods
[68] Fix | Delete
[69] Fix | Delete
[[ $DRACUT_FIRMWARE_PATH ]] || export DRACUT_FIRMWARE_PATH="/lib/firmware/updates:/lib/firmware:/lib/firmware/$kernel"
[70] Fix | Delete
[71] Fix | Delete
# export standard hookdirs
[72] Fix | Delete
[[ $hookdirs ]] || {
[73] Fix | Delete
hookdirs="cmdline pre-udev pre-trigger netroot "
[74] Fix | Delete
hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout "
[75] Fix | Delete
hookdirs+="pre-mount pre-pivot cleanup mount "
[76] Fix | Delete
hookdirs+="emergency shutdown-emergency pre-shutdown shutdown "
[77] Fix | Delete
export hookdirs
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
DRACUT_LDD=${DRACUT_LDD:-ldd}
[81] Fix | Delete
DRACUT_TESTBIN=${DRACUT_TESTBIN:-/bin/sh}
[82] Fix | Delete
DRACUT_LDCONFIG=${DRACUT_LDCONFIG:-ldconfig}
[83] Fix | Delete
[84] Fix | Delete
. $dracutbasedir/dracut-functions.sh
[85] Fix | Delete
[86] Fix | Delete
# Detect lib paths
[87] Fix | Delete
if ! [[ $libdirs ]] ; then
[88] Fix | Delete
if [[ "$(ldd /bin/sh)" == */lib64/* ]] &>/dev/null \
[89] Fix | Delete
&& [[ -d /lib64 ]]; then
[90] Fix | Delete
libdirs+=" /lib64"
[91] Fix | Delete
[[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64"
[92] Fix | Delete
else
[93] Fix | Delete
libdirs+=" /lib"
[94] Fix | Delete
[[ -d /usr/lib ]] && libdirs+=" /usr/lib"
[95] Fix | Delete
fi
[96] Fix | Delete
[97] Fix | Delete
libdirs+=" $(ldconfig_paths)"
[98] Fix | Delete
[99] Fix | Delete
export libdirs
[100] Fix | Delete
fi
[101] Fix | Delete
[102] Fix | Delete
# helper function for check() in module-setup.sh
[103] Fix | Delete
# to check for required installed binaries
[104] Fix | Delete
# issues a standardized warning message
[105] Fix | Delete
require_binaries() {
[106] Fix | Delete
local _module_name="${moddir##*/}"
[107] Fix | Delete
local _ret=0
[108] Fix | Delete
[109] Fix | Delete
if [[ "$1" = "-m" ]]; then
[110] Fix | Delete
_module_name="$2"
[111] Fix | Delete
shift 2
[112] Fix | Delete
fi
[113] Fix | Delete
[114] Fix | Delete
for cmd in "$@"; do
[115] Fix | Delete
if ! find_binary "$cmd" &>/dev/null; then
[116] Fix | Delete
dinfo "dracut module '${_module_name#[0-9][0-9]}' will not be installed, because command '$cmd' could not be found!"
[117] Fix | Delete
((_ret++))
[118] Fix | Delete
fi
[119] Fix | Delete
done
[120] Fix | Delete
return $_ret
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
require_any_binary() {
[124] Fix | Delete
local _module_name="${moddir##*/}"
[125] Fix | Delete
local _ret=1
[126] Fix | Delete
[127] Fix | Delete
if [[ "$1" = "-m" ]]; then
[128] Fix | Delete
_module_name="$2"
[129] Fix | Delete
shift 2
[130] Fix | Delete
fi
[131] Fix | Delete
[132] Fix | Delete
for cmd in "$@"; do
[133] Fix | Delete
if find_binary "$cmd" &>/dev/null; then
[134] Fix | Delete
_ret=0
[135] Fix | Delete
break
[136] Fix | Delete
fi
[137] Fix | Delete
done
[138] Fix | Delete
[139] Fix | Delete
if (( $_ret != 0 )); then
[140] Fix | Delete
dinfo "$_module_name: Could not find any command of '$@'!"
[141] Fix | Delete
return 1
[142] Fix | Delete
fi
[143] Fix | Delete
[144] Fix | Delete
return 0
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
dracut_need_initqueue() {
[148] Fix | Delete
>"$initdir/lib/dracut/need-initqueue"
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
dracut_module_included() {
[152] Fix | Delete
[[ " $mods_to_load $modules_loaded " == *\ $*\ * ]]
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
dracut_no_switch_root() {
[156] Fix | Delete
>"$initdir/lib/dracut/no-switch-root"
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
dracut_module_path() {
[160] Fix | Delete
echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
if ! [[ $DRACUT_INSTALL ]]; then
[164] Fix | Delete
DRACUT_INSTALL=$(find_binary dracut-install)
[165] Fix | Delete
fi
[166] Fix | Delete
[167] Fix | Delete
if ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/dracut-install ]]; then
[168] Fix | Delete
DRACUT_INSTALL=$dracutbasedir/dracut-install
[169] Fix | Delete
elif ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/install/dracut-install ]]; then
[170] Fix | Delete
DRACUT_INSTALL=$dracutbasedir/install/dracut-install
[171] Fix | Delete
fi
[172] Fix | Delete
[173] Fix | Delete
if ! [[ -x $DRACUT_INSTALL ]]; then
[174] Fix | Delete
dfatal "dracut-install not found!"
[175] Fix | Delete
exit 10
[176] Fix | Delete
fi
[177] Fix | Delete
[178] Fix | Delete
if [[ $hostonly == "-h" ]]; then
[179] Fix | Delete
if ! [[ $DRACUT_KERNEL_MODALIASES ]] || ! [[ -f "$DRACUT_KERNEL_MODALIASES" ]]; then
[180] Fix | Delete
export DRACUT_KERNEL_MODALIASES="${DRACUT_TMPDIR}/modaliases"
[181] Fix | Delete
$DRACUT_INSTALL ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES"
[182] Fix | Delete
fi
[183] Fix | Delete
fi
[184] Fix | Delete
[185] Fix | Delete
[[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1
[186] Fix | Delete
inst_dir() {
[187] Fix | Delete
[[ -e ${initdir}/"$1" ]] && return 0 # already there
[188] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@"
[189] Fix | Delete
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@" || :
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
inst() {
[193] Fix | Delete
local _hostonly_install
[194] Fix | Delete
if [[ "$1" == "-H" ]]; then
[195] Fix | Delete
_hostonly_install="-H"
[196] Fix | Delete
shift
[197] Fix | Delete
fi
[198] Fix | Delete
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[199] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
[200] Fix | Delete
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
inst_simple() {
[204] Fix | Delete
local _hostonly_install
[205] Fix | Delete
if [[ "$1" == "-H" ]]; then
[206] Fix | Delete
_hostonly_install="-H"
[207] Fix | Delete
shift
[208] Fix | Delete
fi
[209] Fix | Delete
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[210] Fix | Delete
[[ -e $1 ]] || return 1 # no source
[211] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@"
[212] Fix | Delete
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@" || :
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
inst_symlink() {
[216] Fix | Delete
local _hostonly_install
[217] Fix | Delete
if [[ "$1" == "-H" ]]; then
[218] Fix | Delete
_hostonly_install="-H"
[219] Fix | Delete
shift
[220] Fix | Delete
fi
[221] Fix | Delete
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[222] Fix | Delete
[[ -L $1 ]] || return 1
[223] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
[224] Fix | Delete
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
inst_multiple() {
[228] Fix | Delete
local _ret
[229] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"
[230] Fix | Delete
_ret=$?
[231] Fix | Delete
(($_ret != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
[232] Fix | Delete
return $_ret
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
dracut_install() {
[236] Fix | Delete
inst_multiple "$@"
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
dracut_instmods() {
[240] Fix | Delete
local _silent=0;
[241] Fix | Delete
local i;
[242] Fix | Delete
[[ $no_kernel = yes ]] && return
[243] Fix | Delete
for i in "$@"; do
[244] Fix | Delete
[[ $i == "--silent" ]] && _silent=1
[245] Fix | Delete
done
[246] Fix | Delete
[247] Fix | Delete
$DRACUT_INSTALL \
[248] Fix | Delete
${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@"
[249] Fix | Delete
(($? != 0)) && (($_silent == 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" || :
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
inst_library() {
[253] Fix | Delete
local _hostonly_install
[254] Fix | Delete
if [[ "$1" == "-H" ]]; then
[255] Fix | Delete
_hostonly_install="-H"
[256] Fix | Delete
shift
[257] Fix | Delete
fi
[258] Fix | Delete
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[259] Fix | Delete
[[ -e $1 ]] || return 1 # no source
[260] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
[261] Fix | Delete
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
inst_binary() {
[265] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"
[266] Fix | Delete
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
inst_script() {
[270] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"
[271] Fix | Delete
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
inst_fsck_help() {
[275] Fix | Delete
local _helper="/run/dracut/fsck/fsck_help_$1.txt"
[276] Fix | Delete
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper
[277] Fix | Delete
(($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper || :
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
# Use with form hostonly="$(optional_hostonly)" inst_xxxx <args>
[281] Fix | Delete
# If hosotnly mode is set to "strict", hostonly restrictions will still
[282] Fix | Delete
# be applied, else will ignore hostonly mode and try to install all
[283] Fix | Delete
# given modules.
[284] Fix | Delete
optional_hostonly() {
[285] Fix | Delete
if [[ $hostonly_mode = "strict" ]]; then
[286] Fix | Delete
printf -- "$hostonly"
[287] Fix | Delete
else
[288] Fix | Delete
printf ""
[289] Fix | Delete
fi
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
mark_hostonly() {
[293] Fix | Delete
for i in "$@"; do
[294] Fix | Delete
echo "$i" >> "$initdir/lib/dracut/hostonly-files"
[295] Fix | Delete
done
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
# find symlinks linked to given library file
[299] Fix | Delete
# $1 = library file
[300] Fix | Delete
# Function searches for symlinks by stripping version numbers appended to
[301] Fix | Delete
# library filename, checks if it points to the same target and finally
[302] Fix | Delete
# prints the list of symlinks to stdout.
[303] Fix | Delete
#
[304] Fix | Delete
# Example:
[305] Fix | Delete
# rev_lib_symlinks libfoo.so.8.1
[306] Fix | Delete
# output: libfoo.so.8 libfoo.so
[307] Fix | Delete
# (Only if libfoo.so.8 and libfoo.so exists on host system.)
[308] Fix | Delete
rev_lib_symlinks() {
[309] Fix | Delete
[[ ! $1 ]] && return 0
[310] Fix | Delete
[311] Fix | Delete
local fn="$1" orig="$(readlink -f "$1")" links=''
[312] Fix | Delete
[313] Fix | Delete
[[ ${fn} == *.so.* ]] || return 1
[314] Fix | Delete
[315] Fix | Delete
until [[ ${fn##*.} == so ]]; do
[316] Fix | Delete
fn="${fn%.*}"
[317] Fix | Delete
[[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}"
[318] Fix | Delete
done
[319] Fix | Delete
[320] Fix | Delete
echo "${links}"
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
# attempt to install any programs specified in a udev rule
[324] Fix | Delete
inst_rule_programs() {
[325] Fix | Delete
local _prog _bin
[326] Fix | Delete
[327] Fix | Delete
for _prog in $(sed -nr 's/.*PROGRAM==?"([^ "]+).*/\1/p' "$1"); do
[328] Fix | Delete
_bin=""
[329] Fix | Delete
if [ -x ${udevdir}/$_prog ]; then
[330] Fix | Delete
_bin=${udevdir}/$_prog
[331] Fix | Delete
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
[332] Fix | Delete
_bin=$(find_binary "$_prog") || {
[333] Fix | Delete
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
[334] Fix | Delete
continue;
[335] Fix | Delete
}
[336] Fix | Delete
fi
[337] Fix | Delete
[338] Fix | Delete
[[ $_bin ]] && inst_binary "$_bin"
[339] Fix | Delete
done
[340] Fix | Delete
for _prog in $(sed -nr 's/.*RUN[+=]=?"([^ "]+).*/\1/p' "$1"); do
[341] Fix | Delete
_bin=""
[342] Fix | Delete
if [ -x ${udevdir}/$_prog ]; then
[343] Fix | Delete
_bin=${udevdir}/$_prog
[344] Fix | Delete
elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then
[345] Fix | Delete
_bin=$(find_binary "$_prog") || {
[346] Fix | Delete
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
[347] Fix | Delete
continue;
[348] Fix | Delete
}
[349] Fix | Delete
fi
[350] Fix | Delete
[351] Fix | Delete
[[ $_bin ]] && inst_binary "$_bin"
[352] Fix | Delete
done
[353] Fix | Delete
for _prog in $(sed -nr 's/.*IMPORT\{program\}==?"([^ "]+).*/\1/p' "$1"); do
[354] Fix | Delete
_bin=""
[355] Fix | Delete
if [ -x ${udevdir}/$_prog ]; then
[356] Fix | Delete
_bin=${udevdir}/$_prog
[357] Fix | Delete
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
[358] Fix | Delete
_bin=$(find_binary "$_prog") || {
[359] Fix | Delete
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
[360] Fix | Delete
continue;
[361] Fix | Delete
}
[362] Fix | Delete
fi
[363] Fix | Delete
[364] Fix | Delete
[[ $_bin ]] && dracut_install "$_bin"
[365] Fix | Delete
done
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
# attempt to install any programs specified in a udev rule
[369] Fix | Delete
inst_rule_group_owner() {
[370] Fix | Delete
local i
[371] Fix | Delete
[372] Fix | Delete
for i in $(sed -nr 's/.*OWNER=?"([^ "]+).*/\1/p' "$1"); do
[373] Fix | Delete
if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2>/dev/null; then
[374] Fix | Delete
grep -E "^$i:" /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
[375] Fix | Delete
fi
[376] Fix | Delete
done
[377] Fix | Delete
for i in $(sed -nr 's/.*GROUP=?"([^ "]+).*/\1/p' "$1"); do
[378] Fix | Delete
if ! grep -Eq "^$i:" "$initdir/etc/group" 2>/dev/null; then
[379] Fix | Delete
grep -E "^$i:" /etc/group 2>/dev/null >> "$initdir/etc/group"
[380] Fix | Delete
fi
[381] Fix | Delete
done
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
inst_rule_initqueue() {
[385] Fix | Delete
if grep -q -F initqueue "$1"; then
[386] Fix | Delete
dracut_need_initqueue
[387] Fix | Delete
fi
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
# udev rules always get installed in the same place, so
[391] Fix | Delete
# create a function to install them to make life simpler.
[392] Fix | Delete
inst_rules() {
[393] Fix | Delete
local _target=/etc/udev/rules.d _rule _found
[394] Fix | Delete
[395] Fix | Delete
inst_dir "${udevdir}/rules.d"
[396] Fix | Delete
inst_dir "$_target"
[397] Fix | Delete
for _rule in "$@"; do
[398] Fix | Delete
if [ "${_rule#/}" = "$_rule" ]; then
[399] Fix | Delete
for r in ${udevdir}/rules.d ${hostonly:+/etc/udev/rules.d}; do
[400] Fix | Delete
[[ -e $r/$_rule ]] || continue
[401] Fix | Delete
_found="$r/$_rule"
[402] Fix | Delete
inst_rule_programs "$_found"
[403] Fix | Delete
inst_rule_group_owner "$_found"
[404] Fix | Delete
inst_rule_initqueue "$_found"
[405] Fix | Delete
inst_simple "$_found"
[406] Fix | Delete
done
[407] Fix | Delete
fi
[408] Fix | Delete
for r in '' $dracutbasedir/rules.d/; do
[409] Fix | Delete
# skip rules without an absolute path
[410] Fix | Delete
[[ "${r}$_rule" != /* ]] && continue
[411] Fix | Delete
[[ -f ${r}$_rule ]] || continue
[412] Fix | Delete
_found="${r}$_rule"
[413] Fix | Delete
inst_rule_programs "$_found"
[414] Fix | Delete
inst_rule_group_owner "$_found"
[415] Fix | Delete
inst_rule_initqueue "$_found"
[416] Fix | Delete
inst_simple "$_found" "$_target/${_found##*/}"
[417] Fix | Delete
done
[418] Fix | Delete
[[ $_found ]] || dinfo "Skipping udev rule: $_rule"
[419] Fix | Delete
done
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
inst_rules_wildcard() {
[423] Fix | Delete
local _target=/etc/udev/rules.d _rule _found
[424] Fix | Delete
[425] Fix | Delete
inst_dir "${udevdir}/rules.d"
[426] Fix | Delete
inst_dir "$_target"
[427] Fix | Delete
for _rule in ${udevdir}/rules.d/$1 ${dracutbasedir}/rules.d/$1 ; do
[428] Fix | Delete
[[ -e $_rule ]] || continue
[429] Fix | Delete
inst_rule_programs "$_rule"
[430] Fix | Delete
inst_rule_group_owner "$_rule"
[431] Fix | Delete
inst_rule_initqueue "$_rule"
[432] Fix | Delete
inst_simple "$_rule"
[433] Fix | Delete
_found=$_rule
[434] Fix | Delete
done
[435] Fix | Delete
if [[ -n ${hostonly} ]] ; then
[436] Fix | Delete
for _rule in ${_target}/$1 ; do
[437] Fix | Delete
[[ -f $_rule ]] || continue
[438] Fix | Delete
inst_rule_programs "$_rule"
[439] Fix | Delete
inst_rule_group_owner "$_rule"
[440] Fix | Delete
inst_rule_initqueue "$_rule"
[441] Fix | Delete
inst_simple "$_rule"
[442] Fix | Delete
_found=$_rule
[443] Fix | Delete
done
[444] Fix | Delete
fi
[445] Fix | Delete
[[ $_found ]] || dinfo "Skipping udev rule: $_rule"
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
# make sure that library links are correct and up to date
[449] Fix | Delete
build_ld_cache() {
[450] Fix | Delete
for f in "$dracutsysrootdir"/etc/ld.so.conf "$dracutsysrootdir"/etc/ld.so.conf.d/*; do
[451] Fix | Delete
[[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}"
[452] Fix | Delete
done
[453] Fix | Delete
if ! ldconfig -r "$initdir" -f /etc/ld.so.conf; then
[454] Fix | Delete
if [[ $EUID == 0 ]]; then
[455] Fix | Delete
derror "ldconfig exited ungracefully"
[456] Fix | Delete
else
[457] Fix | Delete
derror "ldconfig might need uid=0 (root) for chroot()"
[458] Fix | Delete
fi
[459] Fix | Delete
fi
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
prepare_udev_rules() {
[463] Fix | Delete
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version | { read v _ ; echo $v ; })
[464] Fix | Delete
[465] Fix | Delete
for f in "$@"; do
[466] Fix | Delete
f="${initdir}/etc/udev/rules.d/$f"
[467] Fix | Delete
[ -e "$f" ] || continue
[468] Fix | Delete
while read line || [ -n "$line" ]; do
[469] Fix | Delete
if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
[470] Fix | Delete
if [ $UDEVVERSION -ge 174 ]; then
[471] Fix | Delete
printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
[472] Fix | Delete
else
[473] Fix | Delete
printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
[474] Fix | Delete
fi
[475] Fix | Delete
elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
[476] Fix | Delete
if [ $UDEVVERSION -ge 176 ]; then
[477] Fix | Delete
printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
[478] Fix | Delete
else
[479] Fix | Delete
printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
[480] Fix | Delete
fi
[481] Fix | Delete
else
[482] Fix | Delete
echo "$line"
[483] Fix | Delete
fi
[484] Fix | Delete
done < "${f}" > "${f}.new"
[485] Fix | Delete
mv "${f}.new" "$f"
[486] Fix | Delete
done
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
# install function specialized for hooks
[490] Fix | Delete
# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
[491] Fix | Delete
# All hooks should be POSIX/SuS compliant, they will be sourced by init.
[492] Fix | Delete
inst_hook() {
[493] Fix | Delete
if ! [[ -f $3 ]]; then
[494] Fix | Delete
dfatal "Cannot install a hook ($3) that does not exist."
[495] Fix | Delete
dfatal "Aborting initrd creation."
[496] Fix | Delete
exit 1
[497] Fix | Delete
elif ! [[ "$hookdirs" == *$1* ]]; then
[498] Fix | Delete
dfatal "No such hook type $1. Aborting initrd creation."
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function