style: shfmt reformat
reproducible with: ``` $ shfmt_version=3.0.1 $ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt $ chmod u+x shfmt $ ./shfmt -w . ```master
parent
560402c3dc
commit
9a52c3fdb0
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# We don't support srcdir != builddir
|
||||
echo \#buildapi-variable-no-builddir >/dev/null
|
||||
echo \#buildapi-variable-no-builddir > /dev/null
|
||||
|
||||
prefix=/usr
|
||||
|
||||
|
@ -31,24 +31,24 @@ read_arg() {
|
|||
|
||||
while (($# > 0)); do
|
||||
case "${1%%=*}" in
|
||||
--prefix) read_arg prefix "$@" || shift;;
|
||||
--libdir) read_arg libdir "$@" || shift;;
|
||||
--datadir) read_arg datadir "$@" || shift;;
|
||||
--sysconfdir) read_arg sysconfdir "$@" || shift;;
|
||||
--sbindir) read_arg sbindir "$@" || shift;;
|
||||
--mandir) read_arg mandir "$@" || shift;;
|
||||
--disable-documentation) enable_documentation=no;;
|
||||
--program-prefix) read_arg programprefix "$@" || shift;;
|
||||
--exec-prefix) read_arg execprefix "$@" || shift;;
|
||||
--bindir) read_arg bindir "$@" || shift;;
|
||||
--includedir) read_arg includedir "$@" || shift;;
|
||||
--libexecdir) read_arg libexecdir "$@" || shift;;
|
||||
--localstatedir) read_arg localstatedir "$@" || shift;;
|
||||
--sharedstatedir) read_arg sharedstatedir "$@" || shift;;
|
||||
--infodir) read_arg infodir "$@" || shift;;
|
||||
--systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift;;
|
||||
--bashcompletiondir) read_arg bashcompletiondir "$@" || shift;;
|
||||
*) echo "Ignoring unknown option '$1'";;
|
||||
--prefix) read_arg prefix "$@" || shift ;;
|
||||
--libdir) read_arg libdir "$@" || shift ;;
|
||||
--datadir) read_arg datadir "$@" || shift ;;
|
||||
--sysconfdir) read_arg sysconfdir "$@" || shift ;;
|
||||
--sbindir) read_arg sbindir "$@" || shift ;;
|
||||
--mandir) read_arg mandir "$@" || shift ;;
|
||||
--disable-documentation) enable_documentation=no ;;
|
||||
--program-prefix) read_arg programprefix "$@" || shift ;;
|
||||
--exec-prefix) read_arg execprefix "$@" || shift ;;
|
||||
--bindir) read_arg bindir "$@" || shift ;;
|
||||
--includedir) read_arg includedir "$@" || shift ;;
|
||||
--libexecdir) read_arg libexecdir "$@" || shift ;;
|
||||
--localstatedir) read_arg localstatedir "$@" || shift ;;
|
||||
--sharedstatedir) read_arg sharedstatedir "$@" || shift ;;
|
||||
--infodir) read_arg infodir "$@" || shift ;;
|
||||
--systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift ;;
|
||||
--bashcompletiondir) read_arg bashcompletiondir "$@" || shift ;;
|
||||
*) echo "Ignoring unknown option '$1'" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -58,7 +58,7 @@ if ! ${PKG_CONFIG} --exists --print-errors " libkmod >= 23 "; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF >conftest.c
|
||||
cat << EOF > conftest.c
|
||||
#include <fts.h>
|
||||
int main() {
|
||||
return 0;
|
||||
|
@ -66,17 +66,17 @@ int main() {
|
|||
EOF
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
${CC} $CFLAGS $LDFLAGS conftest.c >/dev/null 2>&1
|
||||
${CC} $CFLAGS $LDFLAGS conftest.c > /dev/null 2>&1
|
||||
ret=$?
|
||||
rm -f conftest.c a.out
|
||||
|
||||
# musl doesn't have fts.h included
|
||||
if test $ret -ne 0; then
|
||||
echo "dracut needs fts development files." >&2
|
||||
exit 1
|
||||
echo "dracut needs fts development files." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF >conftest.c
|
||||
cat << EOF > conftest.c
|
||||
#include <fts.h>
|
||||
int main(void) {
|
||||
fts_open(0, 0, 0);
|
||||
|
@ -86,23 +86,23 @@ EOF
|
|||
|
||||
found=no
|
||||
for lib in "-lc" "-lfts"; do
|
||||
# shellcheck disable=SC2086
|
||||
${CC} $CFLAGS $LDFLAGS conftest.c -Wl,$lib >/dev/null 2>&1
|
||||
ret=$?
|
||||
if test $ret -eq 0; then
|
||||
FTS_LIBS="$lib"
|
||||
found=yes
|
||||
break;
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
${CC} $CFLAGS $LDFLAGS conftest.c -Wl,$lib > /dev/null 2>&1
|
||||
ret=$?
|
||||
if test $ret -eq 0; then
|
||||
FTS_LIBS="$lib"
|
||||
found=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
rm -f conftest.c a.out
|
||||
|
||||
if test $found = no; then
|
||||
echo "dracut couldn't find usable fts library" >&2
|
||||
exit 1
|
||||
echo "dracut couldn't find usable fts library" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > Makefile.inc.$$ <<EOF
|
||||
cat > Makefile.inc.$$ << EOF
|
||||
prefix ?= ${prefix}
|
||||
libdir ?= ${libdir:-${prefix}/lib}
|
||||
datadir ?= ${datadir:-${prefix}/share}
|
||||
|
|
|
@ -15,16 +15,17 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__contains_word () {
|
||||
local word="$1"; shift
|
||||
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
|
||||
return 1
|
||||
__contains_word() {
|
||||
local word="$1"
|
||||
shift
|
||||
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
_dracut() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-f -v -q -l -H -h -M -N
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD - 1]}
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-f -v -q -l -H -h -M -N
|
||||
--ro-mnt --force --kernel-only --no-kernel --strip --nostrip
|
||||
--hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf
|
||||
--lvmconf --nolvmconf --debug --profile --verbose --quiet
|
||||
|
@ -32,65 +33,74 @@ _dracut() {
|
|||
--xz --zstd --no-compress --gzip --list-modules --show-modules --keep
|
||||
--printsize --regenerate-all --noimageifnotneeded --early-microcode
|
||||
--no-early-microcode --print-cmdline --reproducible --uefi'
|
||||
[ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
|
||||
[ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
|
||||
--omit-drivers --modules --omit --drivers --filesystems --install
|
||||
--fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
|
||||
--kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
|
||||
--kernel-cmdline --sshkey --persistent-policy --install-optional
|
||||
--loginstall --uefi-stub --kernel-image
|
||||
'
|
||||
)
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--kmoddir | -k | --fwdir | --confdir | --tmpdir)
|
||||
comps=$(compgen -d -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
-c | --conf | --sshkey | --add-fstab | --add-device | -I | --install | --install-optional)
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
-a | -m | -o | --add | --modules | --omit)
|
||||
comps=$(dracut --list-modules 2> /dev/null)
|
||||
;;
|
||||
--persistent-policy)
|
||||
comps=$(
|
||||
cd /dev/disk/ || return 0
|
||||
printf -- "%s " *
|
||||
)
|
||||
;;
|
||||
--kver)
|
||||
comps=$(
|
||||
cd /lib/modules || return 0
|
||||
echo [0-9]*
|
||||
)
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=($(compgen -W '$comps' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $cur = -* ]]; then
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
local args
|
||||
_count_args
|
||||
if [[ $args -eq 1 ]]; then
|
||||
_filedir
|
||||
return 0
|
||||
elif [[ $args -eq 2 ]]; then
|
||||
# shellcheck disable=SC2034
|
||||
comps=$(
|
||||
cd /lib/modules || return 0
|
||||
echo [0-9]*
|
||||
)
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--kmoddir|-k|--fwdir|--confdir|--tmpdir)
|
||||
comps=$(compgen -d -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
-c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
-a|-m|-o|--add|--modules|--omit)
|
||||
comps=$(dracut --list-modules 2>/dev/null)
|
||||
;;
|
||||
--persistent-policy)
|
||||
comps=$(cd /dev/disk/ || return 0; printf -- "%s " *)
|
||||
;;
|
||||
--kver)
|
||||
comps=$(cd /lib/modules || return 0; echo [0-9]*)
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $cur = -* ]]; then
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
local args
|
||||
_count_args
|
||||
if [[ $args -eq 1 ]]; then
|
||||
_filedir
|
||||
return 0
|
||||
elif [[ $args -eq 2 ]]; then
|
||||
# shellcheck disable=SC2034
|
||||
comps=$(cd /lib/modules || return 0; echo [0-9]*)
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=($(compgen -W '$comps' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _dracut dracut
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
dwarning() {
|
||||
echo "Warning: $*" >&2
|
||||
}
|
||||
|
@ -49,27 +48,46 @@ line and /boot/dracut/
|
|||
EOF
|
||||
}
|
||||
|
||||
|
||||
imagedir=/boot/dracut/
|
||||
overlay=/var/lib/dracut/overlay
|
||||
|
||||
while (($# > 0)); do
|
||||
case $1 in
|
||||
-f|--force) force=yes;;
|
||||
-i|--imagedir) imagedir=$2;shift;;
|
||||
-o|--overlaydir) overlay=$2;shift;;
|
||||
--nooverlay) no_overlay=yes;shift;;
|
||||
--noimagedir) no_imagedir=yes;shift;;
|
||||
-h|--help) usage; exit 1 ;;
|
||||
--debug) export debug="yes";;
|
||||
-v|--verbose) beverbose="yes";;
|
||||
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
|
||||
-f | --force) force=yes ;;
|
||||
-i | --imagedir)
|
||||
imagedir=$2
|
||||
shift
|
||||
;;
|
||||
-o | --overlaydir)
|
||||
overlay=$2
|
||||
shift
|
||||
;;
|
||||
--nooverlay)
|
||||
no_overlay=yes
|
||||
shift
|
||||
;;
|
||||
--noimagedir)
|
||||
no_imagedir=yes
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
--debug) export debug="yes" ;;
|
||||
-v | --verbose) beverbose="yes" ;;
|
||||
-*)
|
||||
printf "\nUnknown option: %s\n\n" "$1" >&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
outfile=$1; shift
|
||||
outfile=$1
|
||||
shift
|
||||
|
||||
if [[ -z $outfile ]]; then
|
||||
derror "No output file specified."
|
||||
|
@ -77,7 +95,8 @@ if [[ -z $outfile ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
baseimage=$1; shift
|
||||
baseimage=$1
|
||||
shift
|
||||
|
||||
if [[ -z $baseimage ]]; then
|
||||
derror "No base image specified."
|
||||
|
@ -103,8 +122,11 @@ fi
|
|||
if [[ ! $no_overlay ]]; then
|
||||
ofile="$imagedir/90-overlay.img"
|
||||
dinfo "Creating image $ofile from directory $overlay"
|
||||
type pigz &>/dev/null && gzip=pigz || gzip=gzip
|
||||
( cd "$overlay" || return 1 ; find . |cpio --quiet -H newc -o |$gzip -9 > "$ofile"; )
|
||||
type pigz &> /dev/null && gzip=pigz || gzip=gzip
|
||||
(
|
||||
cd "$overlay" || return 1
|
||||
find . | cpio --quiet -H newc -o | $gzip -9 > "$ofile"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ ! $no_imagedir ]]; then
|
||||
|
@ -113,7 +135,7 @@ if [[ ! $no_imagedir ]]; then
|
|||
done
|
||||
fi
|
||||
|
||||
images+=( "$@" )
|
||||
images+=("$@")
|
||||
|
||||
dinfo "Using base image $baseimage"
|
||||
cat -- "$baseimage" > "$outfile"
|
||||
|
|
|
@ -25,7 +25,6 @@ is_func() {
|
|||
[[ "$(type -t "$1")" = "function" ]]
|
||||
}
|
||||
|
||||
|
||||
# Generic substring function. If $2 is in $1, return 0.
|
||||
strstr() { [[ $1 = *"$2"* ]]; }
|
||||
# Generic glob matching function. If glob pattern $2 matches anywhere in $1, OK
|
||||
|
@ -49,15 +48,15 @@ find_binary() {
|
|||
|
||||
if [[ "$1" == *.so* ]]; then
|
||||
# shellcheck disable=SC2154
|
||||
for l in $libdirs ; do
|
||||
for l in $libdirs; do
|
||||
_path="${l}${_delim}${1}"
|
||||
if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then
|
||||
if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &> /dev/null; }; then
|
||||
printf "%s\n" "${_path}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_path="${_delim}${1}"
|
||||
if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then
|
||||
if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &> /dev/null; }; then
|
||||
printf "%s\n" "${_path}"
|
||||
return 0
|
||||
fi
|
||||
|
@ -69,9 +68,9 @@ find_binary() {
|
|||
return 0
|
||||
fi
|
||||
fi
|
||||
for p in $DRACUT_PATH ; do
|
||||
for p in $DRACUT_PATH; do
|
||||
_path="${p}${_delim}${1}"
|
||||
if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
|
||||
if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
|
||||
printf "%s\n" "${_path}"
|
||||
return 0
|
||||
fi
|
||||
|
@ -81,9 +80,8 @@ find_binary() {
|
|||
type -P "${1##*/}"
|
||||
}
|
||||
|
||||
ldconfig_paths()
|
||||
{
|
||||
$DRACUT_LDCONFIG ${dracutsysrootdir:+-r ${dracutsysrootdir} -f /etc/ld.so.conf} -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
|
||||
ldconfig_paths() {
|
||||
$DRACUT_LDCONFIG ${dracutsysrootdir:+-r ${dracutsysrootdir} -f /etc/ld.so.conf} -pN 2> /dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
|
||||
}
|
||||
|
||||
# Version comparision function. Assumes Linux style version scheme.
|
||||
|
@ -98,23 +96,26 @@ vercmp() {
|
|||
read -a _n2 <<< "${3//./ }"
|
||||
local _i _res
|
||||
|
||||
for ((_i=0; ; _i++))
|
||||
do
|
||||
if [[ ! ${_n1[_i]}${_n2[_i]} ]]; then _res=0
|
||||
elif ((${_n1[_i]:-0} > ${_n2[_i]:-0})); then _res=1
|
||||
elif ((${_n1[_i]:-0} < ${_n2[_i]:-0})); then _res=2
|
||||
else continue
|
||||
for ((_i = 0; ; _i++)); do
|
||||
if [[ ! ${_n1[_i]}${_n2[_i]} ]]; then
|
||||
_res=0
|
||||
elif ((${_n1[_i]:-0} > ${_n2[_i]:-0})); then
|
||||
_res=1
|
||||
elif ((${_n1[_i]:-0} < ${_n2[_i]:-0})); then
|
||||
_res=2
|
||||
else
|
||||
continue
|
||||
fi
|
||||
break
|
||||
done
|
||||
|
||||
case $_op in
|
||||
gt) ((_res == 1));;
|
||||
ge) ((_res != 2));;
|
||||
eq) ((_res == 0));;
|
||||
le) ((_res != 1));;
|
||||
lt) ((_res == 2));;
|
||||
ne) ((_res != 0));;
|
||||
gt) ((_res == 1)) ;;
|
||||
ge) ((_res != 2)) ;;
|
||||
eq) ((_res == 0)) ;;
|
||||
le) ((_res != 1)) ;;
|
||||
lt) ((_res == 2)) ;;
|
||||
ne) ((_res != 0)) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -130,8 +131,7 @@ mksubdirs() {
|
|||
print_vars() {
|
||||
local _var _value
|
||||
|
||||
for _var in "$@"
|
||||
do
|
||||
for _var in "$@"; do
|
||||
eval printf -v _value "%s" \""\$$_var"\"
|
||||
[[ ${_value} ]] && printf '%s="%s"\n' "$_var" "$_value"
|
||||
done
|
||||
|
@ -163,10 +163,16 @@ convert_abs_rel() {
|
|||
set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
|
||||
|
||||
# corner case #1 - self looping link
|
||||
[[ "$1" == "$2" ]] && { printf "%s\n" "${1##*/}"; return; }
|
||||
[[ "$1" == "$2" ]] && {
|
||||
printf "%s\n" "${1##*/}"
|
||||
return
|
||||
}
|
||||
|
||||
# corner case #2 - own dir link
|
||||
[[ "${1%/*}" == "$2" ]] && { printf ".\n"; return; }
|
||||
[[ "${1%/*}" == "$2" ]] && {
|
||||
printf ".\n"
|
||||
return
|
||||
}
|
||||
|
||||
read -d '/' -r -a __current <<< "$1"
|
||||
read -d '/' -a __absolute <<< "$2"
|
||||
|
@ -174,28 +180,22 @@ convert_abs_rel() {
|
|||
__abssize=${#__absolute[@]}
|
||||
__cursize=${#__current[@]}
|
||||
|
||||
while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]
|
||||
do
|
||||
(( __level++ ))
|
||||
if (( __level > __abssize || __level > __cursize ))
|
||||
then
|
||||
while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]; do
|
||||
((__level++))
|
||||
if ((__level > __abssize || __level > __cursize)); then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
for ((__i = __level; __i < __cursize-1; __i++))
|
||||
do
|
||||
if ((__i > __level))
|
||||
then
|
||||
for ((__i = __level; __i < __cursize - 1; __i++)); do
|
||||
if ((__i > __level)); then
|
||||
__newpath=$__newpath"/"
|
||||
fi
|
||||
__newpath=$__newpath".."
|
||||
done
|
||||
|
||||
for ((__i = __level; __i < __abssize; __i++))
|
||||
do
|
||||
if [[ -n $__newpath ]]
|
||||
then
|
||||
for ((__i = __level; __i < __abssize; __i++)); do
|
||||
if [[ -n $__newpath ]]; then
|
||||
__newpath=$__newpath"/"
|
||||
fi
|
||||
__newpath=$__newpath${__absolute[__i]}
|
||||
|
@ -204,7 +204,6 @@ convert_abs_rel() {
|
|||
printf -- "%s\n" "$__newpath"
|
||||
}
|
||||
|
||||
|
||||
# get_fs_env <device>
|
||||
# Get and the ID_FS_TYPE variable from udev for a device.
|
||||
# Example:
|
||||
|
@ -216,10 +215,10 @@ get_fs_env() {
|
|||
ID_FS_TYPE=$(blkid -u filesystem -o export -- "$1" \
|
||||
| while read line || [ -n "$line" ]; do
|
||||
if [[ "$line" == TYPE\=* ]]; then
|
||||
printf "%s" "${line#TYPE=}";
|
||||
exit 0;
|
||||
printf "%s" "${line#TYPE=}"
|
||||
exit 0
|
||||
fi
|
||||
done)
|
||||
done)
|
||||
if [[ $ID_FS_TYPE ]]; then
|
||||
printf "%s" "$ID_FS_TYPE"
|
||||
return 0
|
||||
|
@ -234,11 +233,10 @@ get_fs_env() {
|
|||
# 8:2
|
||||
get_maj_min() {
|
||||
local _majmin
|
||||
_majmin="$(stat -L -c '%t:%T' "$1" 2>/dev/null)"
|
||||
_majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)"
|
||||
printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))"
|
||||
}
|
||||
|
||||
|
||||
# get_devpath_block <device>
|
||||
# get the DEVPATH in /sys of a block device
|
||||
get_devpath_block() {
|
||||
|
@ -247,7 +245,7 @@ get_devpath_block() {
|
|||
|
||||
for _i in /sys/block/*/dev /sys/block/*/*/dev; do
|
||||
[[ -e "$_i" ]] || continue
|
||||
if [[ "$_majmin" == "$(<"$_i")" ]]; then
|
||||
if [[ "$_majmin" == "$(< "$_i")" ]]; then
|
||||
printf "%s" "${_i%/dev}"
|
||||
return 0
|
||||
fi
|
||||
|
@ -263,9 +261,9 @@ get_persistent_dev() {
|
|||
[ -z "$_dev" ] && return
|
||||
|
||||
if [[ -n "$persistent_policy" ]]; then
|
||||
_pol="/dev/disk/${persistent_policy}/*"
|
||||
_pol="/dev/disk/${persistent_policy}/*"
|
||||
else
|
||||
_pol=
|
||||
_pol=
|
||||
fi
|
||||
|
||||
for i in \
|
||||
|
@ -276,8 +274,7 @@ get_persistent_dev() {
|
|||
/dev/disk/by-partuuid/* \
|
||||
/dev/disk/by-partlabel/* \
|
||||
/dev/disk/by-id/* \
|
||||
/dev/disk/by-path/* \
|
||||
; do
|
||||
/dev/disk/by-path/*; do
|
||||
[[ -e "$i" ]] || continue
|
||||
[[ $i == /dev/mapper/control ]] && continue
|
||||
[[ $i == /dev/mapper/mpath* ]] && continue
|
||||
|
@ -318,15 +315,20 @@ shorten_persistent_dev() {
|
|||
local _dev="$1"
|
||||
case "$_dev" in
|
||||
/dev/disk/by-uuid/*)
|
||||
printf "%s" "UUID=${_dev##*/}";;
|
||||
printf "%s" "UUID=${_dev##*/}"
|
||||
;;
|
||||
/dev/disk/by-label/*)
|
||||
printf "%s" "LABEL=${_dev##*/}";;
|
||||
printf "%s" "LABEL=${_dev##*/}"
|
||||
;;
|
||||
/dev/disk/by-partuuid/*)
|
||||
printf "%s" "PARTUUID=${_dev##*/}";;
|
||||
printf "%s" "PARTUUID=${_dev##*/}"
|
||||
;;
|
||||
/dev/disk/by-partlabel/*)
|
||||
printf "%s" "PARTLABEL=${_dev##*/}";;
|
||||
printf "%s" "PARTLABEL=${_dev##*/}"
|
||||
;;
|
||||
*)
|
||||
printf "%s" "$_dev";;
|
||||
printf "%s" "$_dev"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -346,7 +348,7 @@ find_block_device() {
|
|||
|
||||
if [[ $use_fstab != yes ]]; then
|
||||
[[ -d $_find_mpt/. ]]
|
||||
findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \
|
||||
findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | {
|
||||
while read _majmin _dev || [ -n "$_dev" ]; do
|
||||
if [[ -b $_dev ]]; then
|
||||
if ! [[ $_majmin ]] || [[ $_majmin == 0:* ]]; then
|
||||
|
@ -363,11 +365,13 @@ find_block_device() {
|
|||
printf "%s\n" "$_dev"
|
||||
return 0
|
||||
fi
|
||||
done; return 1; } && return 0
|
||||
done
|
||||
return 1
|
||||
} && return 0
|
||||
fi
|
||||
# fall back to /etc/fstab
|
||||
|
||||
findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \
|
||||
findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | {
|
||||
while read _majmin _dev || [ -n "$_dev" ]; do
|
||||
if ! [[ $_dev ]]; then
|
||||
_dev="$_majmin"
|
||||
|
@ -386,7 +390,9 @@ find_block_device() {
|
|||
printf "%s\n" "$_dev"
|
||||
return 0
|
||||
fi
|
||||
done; return 1; } && return 0
|
||||
done
|
||||
return 1
|
||||
} && return 0
|
||||
|
||||
return 1
|
||||
}
|
||||
|
@ -403,22 +409,26 @@ find_mp_fstype() {
|
|||
local _fs
|
||||
|
||||
if [[ $use_fstab != yes ]]; then
|
||||
findmnt -e -v -n -o 'FSTYPE' --target "$1" | { \
|
||||
findmnt -e -v -n -o 'FSTYPE' --target "$1" | {
|
||||
while read _fs || [ -n "$_fs" ]; do
|
||||
[[ $_fs ]] || continue
|
||||
[[ $_fs = "autofs" ]] && continue
|
||||
printf "%s" "$_fs"
|
||||
return 0
|
||||
done; return 1; } && return 0
|
||||
done
|
||||
return 1
|
||||
} && return 0
|
||||
fi
|
||||
|
||||
findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | { \
|
||||
findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | {
|
||||
while read _fs || [ -n "$_fs" ]; do
|
||||
[[ $_fs ]] || continue
|
||||
[[ $_fs = "autofs" ]] && continue
|
||||
printf "%s" "$_fs"
|
||||
return 0
|
||||
done; return 1; } && return 0
|
||||
done
|
||||
return 1
|
||||
} && return 0
|
||||
|
||||
return 1
|
||||
}
|
||||
|
@ -439,22 +449,26 @@ find_dev_fstype() {
|
|||
fi
|
||||
|
||||
if [[ $use_fstab != yes ]]; then
|
||||
findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev" | { \
|
||||
findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev" | {
|
||||
while read _fs || [ -n "$_fs" ]; do
|
||||
[[ $_fs ]] || continue
|
||||
[[ $_fs = "autofs" ]] && continue
|
||||
printf "%s" "$_fs"
|
||||
return 0
|
||||
done; return 1; } && return 0
|
||||
done
|
||||
return 1
|
||||
} && return 0
|
||||
fi
|
||||
|
||||
findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev" | { \
|
||||
findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev" | {
|
||||
while read _fs || [ -n "$_fs" ]; do
|
||||
[[ $_fs ]] || continue
|
||||
[[ $_fs = "autofs" ]] && continue
|
||||
printf "%s" "$_fs"
|
||||
return 0
|
||||
done; return 1; } && return 0
|
||||
done
|
||||
return 1
|
||||
} && return 0
|
||||
|
||||
return 1
|
||||
}
|
||||
|
@ -469,7 +483,7 @@ find_dev_fstype() {
|
|||
# rw,relatime,discard,data=ordered
|
||||
find_mp_fsopts() {
|
||||
if [[ $use_fstab != yes ]]; then
|
||||
findmnt -e -v -n -o 'OPTIONS' --target "$1" 2>/dev/null && return 0
|
||||
findmnt -e -v -n -o 'OPTIONS' --target "$1" 2> /dev/null && return 0
|
||||
fi
|
||||
|
||||
findmnt --fstab -e -v -n -o 'OPTIONS' --target "$1"
|
||||
|
@ -492,36 +506,32 @@ find_dev_fsopts() {
|
|||
fi
|
||||
|
||||
if [[ $use_fstab != yes ]]; then
|
||||
findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2>/dev/null && return 0
|
||||
findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2> /dev/null && return 0
|
||||
fi
|
||||
|
||||
findmnt --fstab -e -v -n -o 'OPTIONS' --source "$_find_dev"
|
||||
}
|
||||
|
||||
|
||||
# finds the major:minor of the block device backing the root filesystem.
|
||||
find_root_block_device() { find_block_device /; }
|
||||
|
||||
# for_each_host_dev_fs <func>
|
||||
# Execute "<func> <dev> <filesystem>" for every "<dev> <fs>" pair found
|
||||
# in ${host_fs_types[@]}
|
||||
for_each_host_dev_fs()
|
||||
{
|
||||
for_each_host_dev_fs() {
|
||||
local _func="$1"
|
||||
local _dev
|
||||
local _ret=1
|
||||
|
||||
[[ "${#host_fs_types[@]}" ]] || return 2
|
||||
|
||||
|
||||
for _dev in "${!host_fs_types[@]}"; do
|
||||
$_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0
|
||||
done
|
||||
return $_ret
|
||||
}
|
||||
|
||||
host_fs_all()
|
||||
{
|
||||
host_fs_all() {
|
||||
printf "%s\n" "${host_fs_types[@]}"
|
||||
}
|
||||
|
||||
|
@ -535,12 +545,12 @@ check_block_and_slaves() {
|
|||
if ! lvm_internal_dev $2; then "$1" $2 && return; fi
|
||||
check_vol_slaves "$@" && return 0
|
||||
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
|
||||
check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0
|
||||
check_block_and_slaves $1 $(< "/sys/dev/block/$2/../dev") && return 0
|
||||
fi
|
||||
for _x in /sys/dev/block/$2/slaves/*; do
|
||||
[[ -f $_x/dev ]] || continue
|
||||
[[ $_x/subsystem -ef /sys/class/block ]] || continue
|
||||
check_block_and_slaves $1 $(<"$_x/dev") && return 0
|
||||
check_block_and_slaves $1 $(< "$_x/dev") && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
@ -553,20 +563,19 @@ check_block_and_slaves_all() {
|
|||
fi
|
||||
check_vol_slaves_all "$@" && return 0
|
||||
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
|
||||
check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
|
||||
check_block_and_slaves_all $1 $(< "/sys/dev/block/$2/../dev") && _ret=0
|
||||
fi
|
||||
for _x in /sys/dev/block/$2/slaves/*; do
|
||||
[[ -f $_x/dev ]] || continue
|
||||
[[ $_x/subsystem -ef /sys/class/block ]] || continue
|
||||
check_block_and_slaves_all $1 $(<"$_x/dev") && _ret=0
|
||||
check_block_and_slaves_all $1 $(< "$_x/dev") && _ret=0
|
||||
done
|
||||
return $_ret
|
||||
}
|
||||
# for_each_host_dev_and_slaves <func>
|
||||
# Execute "<func> <dev>" for every "<dev>" found
|
||||
# in ${host_devs[@]} and their slaves
|
||||
for_each_host_dev_and_slaves_all()
|
||||
{
|
||||
for_each_host_dev_and_slaves_all() {
|
||||
local _func="$1"
|
||||
local _dev
|
||||
local _ret=1
|
||||
|
@ -582,8 +591,7 @@ for_each_host_dev_and_slaves_all()
|
|||
return $_ret
|
||||
}
|
||||
|
||||
for_each_host_dev_and_slaves()
|
||||
{
|
||||
for_each_host_dev_and_slaves() {
|
||||
local _func="$1"
|
||||
local _dev
|
||||
|
||||
|
@ -607,13 +615,12 @@ check_vol_slaves() {
|
|||
_majmin="$2"
|
||||
_lv="/dev/block/$_majmin"
|
||||
_dm=/sys/dev/block/$_majmin/dm
|
||||
[[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
|
||||
_vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
|
||||
[[ -f $_dm/uuid && $(< $_dm/uuid) =~ LVM-* ]] || return 1
|
||||
_vg=$(dmsetup splitname --noheadings -o vg_name $(< "$_dm/name"))
|
||||
# strip space
|
||||
_vg="${_vg//[[:space:]]/}"
|
||||
if [[ $_vg ]]; then
|
||||
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
|
||||
do
|
||||
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2> /dev/null); do
|
||||
check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
|
||||
done
|
||||
fi
|
||||
|
@ -625,19 +632,18 @@ check_vol_slaves_all() {
|
|||
_majmin="$2"
|
||||
_lv="/dev/block/$_majmin"
|
||||
_dm="/sys/dev/block/$_majmin/dm"
|
||||
[[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
|
||||
_vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
|
||||
[[ -f $_dm/uuid && $(< $_dm/uuid) =~ LVM-* ]] || return 1
|
||||
_vg=$(dmsetup splitname --noheadings -o vg_name $(< "$_dm/name"))
|
||||
# strip space
|
||||
_vg="${_vg//[[:space:]]/}"
|
||||
if [[ $_vg ]]; then
|
||||
# when filter/global_filter is set, lvm may be failed
|
||||
lvm lvs --noheadings -o vg_name $_vg 2>/dev/null 1>/dev/null
|
||||
lvm lvs --noheadings -o vg_name $_vg 2> /dev/null 1> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
|
||||
do
|
||||
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2> /dev/null); do
|
||||
check_block_and_slaves_all $1 $(get_maj_min $_pv)
|
||||
done
|
||||
return 0
|
||||
|
@ -645,8 +651,6 @@ check_vol_slaves_all() {
|
|||
return 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
# fs_get_option <filesystem options> <search for option>
|
||||
# search for a specific option in a bunch of filesystem options
|
||||
# and return the value
|
||||
|
@ -662,13 +666,13 @@ fs_get_option() {
|
|||
$_option=*)
|
||||
echo ${1#${_option}=}
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
check_kernel_config()
|
||||
{
|
||||
check_kernel_config() {
|
||||
local _config_opt="$1"
|
||||
local _config_file
|
||||
[[ -f $dracutsysrootdir/boot/config-$kernel ]] \
|
||||
|
@ -686,13 +690,12 @@ check_kernel_config()
|
|||
# 0 if the kernel module is either built-in or available
|
||||
# 1 if the kernel module is not enabled
|
||||
check_kernel_module() {
|
||||
modprobe -S $kernel --dry-run $1 &>/dev/null || return 1
|
||||
modprobe -S $kernel --dry-run $1 &> /dev/null || return 1
|
||||
}
|
||||
|
||||
# get_cpu_vendor
|
||||
# Only two values are returned: AMD or Intel
|
||||
get_cpu_vendor ()
|
||||
{
|
||||
get_cpu_vendor() {
|
||||
if grep -qE AMD /proc/cpuinfo; then
|
||||
printf "AMD"
|
||||
fi
|
||||
|
@ -703,11 +706,10 @@ get_cpu_vendor ()
|
|||
|
||||
# get_host_ucode
|
||||
# Get the hosts' ucode file based on the /proc/cpuinfo
|
||||
get_ucode_file ()
|
||||
{
|
||||
local family=`grep -E "cpu family" /proc/cpuinfo | head -1 | sed s/.*:\ //`
|
||||
local model=`grep -E "model" /proc/cpuinfo |grep -v name | head -1 | sed s/.*:\ //`
|
||||
local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
|
||||
get_ucode_file() {
|
||||
local family=$(grep -E "cpu family" /proc/cpuinfo | head -1 | sed s/.*:\ //)
|
||||
local model=$(grep -E "model" /proc/cpuinfo | grep -v name | head -1 | sed s/.*:\ //)
|
||||
local stepping=$(grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //)
|
||||
|
||||
if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
|
||||
if [[ $family -ge 21 ]]; then
|
||||
|
@ -726,9 +728,9 @@ get_ucode_file ()
|
|||
# If it is an LVM device, touch only devices which have /dev/VG/LV symlink.
|
||||
lvm_internal_dev() {
|
||||
local dev_dm_dir=/sys/dev/block/$1/dm
|
||||
[[ ! -f $dev_dm_dir/uuid || $(<$dev_dm_dir/uuid) != LVM-* ]] && return 1 # Not an LVM device
|
||||
[[ ! -f $dev_dm_dir/uuid || $(< $dev_dm_dir/uuid) != LVM-* ]] && return 1 # Not an LVM device
|
||||
local DM_VG_NAME DM_LV_NAME DM_LV_LAYER
|
||||
eval $(dmsetup splitname --nameprefixes --noheadings --rows "$(<$dev_dm_dir/name)" 2>/dev/null)
|
||||
eval $(dmsetup splitname --nameprefixes --noheadings --rows "$(< $dev_dm_dir/name)" 2> /dev/null)
|
||||
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 0 # Better skip this!
|
||||
[[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]]
|
||||
}
|
||||
|
@ -737,9 +739,9 @@ btrfs_devs() {
|
|||
local _mp="$1"
|
||||
btrfs device usage "$_mp" \
|
||||
| while read _dev _rest; do
|
||||
str_starts "$_dev" "/" || continue
|
||||
_dev=${_dev%,}
|
||||
printf -- "%s\n" "$_dev"
|
||||
str_starts "$_dev" "/" || continue
|
||||
_dev=${_dev%,}
|
||||
printf -- "%s\n" "$_dev"
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -759,8 +761,8 @@ peer_for_addr() {
|
|||
|
||||
# quote periods in IPv4 address
|
||||
qtd=${addr//./\\.}
|
||||
ip -o addr show | \
|
||||
sed -n 's%^.* '"$qtd"' peer \([0-9a-f.:]\{1,\}\(/[0-9]*\)\?\).*$%\1%p'
|
||||
ip -o addr show \
|
||||
| sed -n 's%^.* '"$qtd"' peer \([0-9a-f.:]\{1,\}\(/[0-9]*\)\?\).*$%\1%p'
|
||||
}
|
||||
|
||||
netmask_for_addr() {
|
||||
|
@ -776,12 +778,12 @@ gateway_for_iface() {
|
|||
local ifname=$1 addr=$2
|
||||
|
||||
case $addr in
|
||||
*.*) proto=4;;
|
||||
*:*) proto=6;;
|
||||
*) return;;
|
||||
*.*) proto=4 ;;
|
||||
*:*) proto=6 ;;
|
||||
*) return ;;
|
||||
esac
|
||||
ip -o -$proto route show | \
|
||||
sed -n "s/^default via \([0-9a-z.:]\{1,\}\) dev $ifname .*\$/\1/p"
|
||||
ip -o -$proto route show \
|
||||
| sed -n "s/^default via \([0-9a-z.:]\{1,\}\) dev $ifname .*\$/\1/p"
|
||||
}
|
||||
|
||||
# This works only for ifcfg-style network configuration!
|
||||
|
@ -819,21 +821,24 @@ ip_params_for_remote_addr() {
|
|||
# ifname clause to bind the interface name to a MAC address
|
||||
if [ -d "/sys/class/net/$ifname/bonding" ]; then
|
||||
dinfo "Found bonded interface '${ifname}'. Make sure to provide an appropriate 'bond=' cmdline."
|
||||
elif [ -e "/sys/class/net/$ifname/address" ] ; then
|
||||
elif [ -e "/sys/class/net/$ifname/address" ]; then
|
||||
ifmac=$(cat "/sys/class/net/$ifname/address")
|
||||
[[ $ifmac ]] && printf 'ifname=%s:%s ' "${ifname}" "${ifmac}"
|
||||
fi
|
||||
|
||||
bootproto=$(bootproto_for_iface "$ifname")
|
||||
case $bootproto in
|
||||
dhcp|dhcp6|auto6) ;;
|
||||
dhcp | dhcp6 | auto6) ;;
|
||||
dhcp4)
|
||||
bootproto=dhcp;;
|
||||
static*|"")
|
||||
bootproto=;;
|
||||
bootproto=dhcp
|
||||
;;
|
||||
static* | "")
|
||||
bootproto=
|
||||
;;
|
||||
*)
|
||||
derror "bootproto \"$bootproto\" is unsupported by dracut, trying static configuration"
|
||||
bootproto=;;
|
||||
bootproto=
|
||||
;;
|
||||
esac
|
||||
if [[ $bootproto ]]; then
|
||||
printf 'ip=%s:%s ' "${ifname}" "${bootproto}"
|
||||
|
@ -852,7 +857,7 @@ ip_params_for_remote_addr() {
|
|||
is_unbracketed_ipv6_address "$peer" && peer="[$peer]"
|
||||
is_unbracketed_ipv6_address "$gateway" && gateway="[$gateway]"
|
||||
printf 'ip=%s:%s:%s:%s::%s:none ' \
|
||||
"${local_addr}" "${peer}" "${gateway}" "${netmask}" "${ifname}"
|
||||
"${local_addr}" "${peer}" "${gateway}" "${netmask}" "${ifname}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
|
148
dracut-init.sh
148
dracut-init.sh
|
@ -38,7 +38,7 @@ if ! [[ $dracutbasedir ]]; then
|
|||
dracutbasedir="$(readlink -f $dracutbasedir)"
|
||||
fi
|
||||
|
||||
if ! is_func dinfo >/dev/null 2>&1; then
|
||||
if ! is_func dinfo > /dev/null 2>&1; then
|
||||
# shellcheck source=./dracut-logger.sh
|
||||
. "$dracutbasedir/dracut-logger.sh"
|
||||
dlog_init
|
||||
|
@ -64,7 +64,7 @@ srcmods="$dracutsysrootdir/lib/modules/$kernel/"
|
|||
|
||||
# shellcheck disable=SC2154
|
||||
[[ $drivers_dir ]] && {
|
||||
if ! command -v kmod &>/dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
|
||||
if ! command -v kmod &> /dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
|
||||
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
|
||||
exit 1
|
||||
fi
|
||||
|
@ -91,8 +91,8 @@ DRACUT_LDCONFIG=${DRACUT_LDCONFIG:-ldconfig}
|
|||
. "$dracutbasedir"/dracut-functions.sh
|
||||
|
||||
# Detect lib paths
|
||||
if ! [[ $libdirs ]] ; then
|
||||
if [[ $("$DRACUT_LDD" "$dracutsysrootdir$DRACUT_TESTBIN") == */lib64/* ]] &>/dev/null \
|
||||
if ! [[ $libdirs ]]; then
|
||||
if [[ $("$DRACUT_LDD" "$dracutsysrootdir$DRACUT_TESTBIN") == */lib64/* ]] &> /dev/null \
|
||||
&& [[ -d $dracutsysrootdir/lib64 ]]; then
|
||||
libdirs+=" /lib64"
|
||||
[[ -d $dracutsysrootdir/usr/lib64 ]] && libdirs+=" /usr/lib64"
|
||||
|
@ -120,7 +120,7 @@ require_binaries() {
|
|||
fi
|
||||
|
||||
for cmd in "$@"; do
|
||||
if ! find_binary "$cmd" &>/dev/null; then
|
||||
if ! find_binary "$cmd" &> /dev/null; then
|
||||
dinfo "dracut module '${_module_name#[0-9][0-9]}' will not be installed, because command '$cmd' could not be found!"
|
||||
((_ret++))
|
||||
fi
|
||||
|
@ -138,13 +138,13 @@ require_any_binary() {
|
|||
fi
|
||||
|
||||
for cmd in "$@"; do
|
||||
if find_binary "$cmd" &>/dev/null; then
|
||||
if find_binary "$cmd" &> /dev/null; then
|
||||
_ret=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if (( _ret != 0 )); then
|
||||
if ((_ret != 0)); then
|
||||
dinfo "$_module_name: Could not find any command of '$*'!"
|
||||
return 1
|
||||
fi
|
||||
|
@ -153,7 +153,7 @@ require_any_binary() {
|
|||
}
|
||||
|
||||
dracut_need_initqueue() {
|
||||
: >"$initdir/lib/dracut/need-initqueue"
|
||||
: > "$initdir/lib/dracut/need-initqueue"
|
||||
}
|
||||
|
||||
dracut_module_included() {
|
||||
|
@ -162,7 +162,7 @@ dracut_module_included() {
|
|||
}
|
||||
|
||||
dracut_no_switch_root() {
|
||||
: >"$initdir/lib/dracut/no-switch-root"
|
||||
: > "$initdir/lib/dracut/no-switch-root"
|
||||
}
|
||||
|
||||
dracut_module_path() {
|
||||
|
@ -193,11 +193,11 @@ fi
|
|||
# DRACUT_INSTALL="dracut-install --debug"
|
||||
# in which case the string cannot be tested for being executable.
|
||||
DRINSTALLPARTS=0
|
||||
for i in $DRACUT_INSTALL ; do
|
||||
DRINSTALLPARTS=$((DRINSTALLPARTS+1))
|
||||
for i in $DRACUT_INSTALL; do
|
||||
DRINSTALLPARTS=$((DRINSTALLPARTS + 1))
|
||||
done
|
||||
|
||||
if [[ $DRINSTALLPARTS = 1 ]] && ! command -v "$DRACUT_INSTALL" > /dev/null 2>&1 ; then
|
||||
if [[ $DRINSTALLPARTS = 1 ]] && ! command -v "$DRACUT_INSTALL" > /dev/null 2>&1; then
|
||||
dfatal "dracut-install not found!"
|
||||
exit 10
|
||||
fi
|
||||
|
@ -211,7 +211,7 @@ fi
|
|||
|
||||
[[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1
|
||||
inst_dir() {
|
||||
[[ -e ${initdir}/"$1" ]] && return 0 # already there
|
||||
[[ -e ${initdir}/"$1" ]] && return 0 # already there
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"
|
||||
fi
|
||||
|
@ -223,7 +223,7 @@ inst() {
|
|||
_hostonly_install="-H"
|
||||
shift
|
||||
fi
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
# shellcheck disable=SC2154
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
|
||||
|
@ -236,8 +236,8 @@ inst_simple() {
|
|||
_hostonly_install="-H"
|
||||
shift
|
||||
fi
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
[[ -e $1 ]] || return 1 # no source
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
[[ -e $1 ]] || return 1 # no source
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@" || :
|
||||
fi
|
||||
|
@ -249,20 +249,20 @@ inst_symlink() {
|
|||
_hostonly_install="-H"
|
||||
shift
|
||||
fi
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
[[ -L $1 ]] || return 1
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
|
||||
fi
|
||||
}
|
||||
|
||||
inst_multiple() {
|
||||
local _ret
|
||||
if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
|
||||
if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
|
||||
return 0
|
||||
else
|
||||
_ret=$?
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
|
||||
return $_ret
|
||||
fi
|
||||
}
|
||||
|
@ -272,8 +272,8 @@ dracut_install() {
|
|||
}
|
||||
|
||||
dracut_instmods() {
|
||||
local _silent=0;
|
||||
local i;
|
||||
local _silent=0
|
||||
local i
|
||||
# shellcheck disable=SC2154
|
||||
[[ $no_kernel = yes ]] && return
|
||||
for i in "$@"; do
|
||||
|
@ -296,29 +296,29 @@ inst_library() {
|
|||
_hostonly_install="-H"
|
||||
shift
|
||||
fi
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
[[ -e $1 ]] || return 1 # no source
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
|
||||
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
|
||||
[[ -e $1 ]] || return 1 # no source
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
|
||||
fi
|
||||
}
|
||||
|
||||
inst_binary() {
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
|
||||
fi
|
||||
}
|
||||
|
||||
inst_script() {
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
|
||||
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
|
||||
fi
|
||||
}
|
||||
|
||||
inst_fsck_help() {
|
||||
local _helper="/run/dracut/fsck/fsck_help_$1.txt"
|
||||
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper"; then
|
||||
derror "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper" || :
|
||||
derror "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper" || :
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ rev_lib_symlinks() {
|
|||
|
||||
until [[ ${_fn##*.} == so ]]; do
|
||||
_fn="${_fn%.*}"
|
||||
[[ -L ${_fn} ]] && [[ $(readlink -f "${_fn}") == "${_orig}" ]] && _links+=( "${_fn}" )
|
||||
[[ -L ${_fn} ]] && [[ $(readlink -f "${_fn}") == "${_orig}" ]] && _links+=("${_fn}")
|
||||
done
|
||||
|
||||
echo "${_links[*]}}"
|
||||
|
@ -385,7 +385,7 @@ inst_rule_programs() {
|
|||
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
|
||||
_bin=$(find_binary "$_prog") || {
|
||||
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
|
||||
continue;
|
||||
continue
|
||||
}
|
||||
fi
|
||||
|
||||
|
@ -400,7 +400,7 @@ inst_rule_programs() {
|
|||
elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then
|
||||
_bin=$(find_binary "$_prog") || {
|
||||
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
|
||||
continue;
|
||||
continue
|
||||
}
|
||||
fi
|
||||
|
||||
|
@ -415,7 +415,7 @@ inst_rule_programs() {
|
|||
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
|
||||
_bin=$(find_binary "$_prog") || {
|
||||
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
|
||||
continue;
|
||||
continue
|
||||
}
|
||||
fi
|
||||
|
||||
|
@ -429,15 +429,15 @@ inst_rule_group_owner() {
|
|||
|
||||
# shellcheck disable=SC2013
|
||||
for i in $(sed -nr 's/.*OWNER=?"([^ "]+).*/\1/p' "$1"); do
|
||||
if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2>/dev/null; then
|
||||
grep -E "^$i:" "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
|
||||
if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2> /dev/null; then
|
||||
grep -E "^$i:" "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
|
||||
fi
|
||||
done
|
||||
|
||||
# shellcheck disable=SC2013
|
||||
for i in $(sed -nr 's/.*GROUP=?"([^ "]+).*/\1/p' "$1"); do
|
||||
if ! grep -Eq "^$i:" "$initdir/etc/group" 2>/dev/null; then
|
||||
grep -E "^$i:" "$dracutsysrootdir"/etc/group 2>/dev/null >> "$initdir/etc/group"
|
||||
if ! grep -Eq "^$i:" "$initdir/etc/group" 2> /dev/null; then
|
||||
grep -E "^$i:" "$dracutsysrootdir"/etc/group 2> /dev/null >> "$initdir/etc/group"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ inst_rules_wildcard() {
|
|||
|
||||
inst_dir "${udevdir}/rules.d"
|
||||
inst_dir "$_target"
|
||||
for _rule in ${udevdir}/rules.d/$1 ${dracutbasedir}/rules.d/$1 ; do
|
||||
for _rule in ${udevdir}/rules.d/$1 ${dracutbasedir}/rules.d/$1; do
|
||||
[[ -e $_rule ]] || continue
|
||||
inst_rule_programs "$_rule"
|
||||
inst_rule_group_owner "$_rule"
|
||||
|
@ -493,8 +493,8 @@ inst_rules_wildcard() {
|
|||
inst_simple "$_rule"
|
||||
_found=$_rule
|
||||
done
|
||||
if [[ -n ${hostonly} ]] ; then
|
||||
for _rule in ${_target}/$1 ; do
|
||||
if [[ -n ${hostonly} ]]; then
|
||||
for _rule in ${_target}/$1; do
|
||||
[[ -f $_rule ]] || continue
|
||||
inst_rule_programs "$_rule"
|
||||
inst_rule_group_owner "$_rule"
|
||||
|
@ -526,13 +526,13 @@ prepare_udev_rules() {
|
|||
[ -e "$f" ] || continue
|
||||
while read -r line || [ -n "$line" ]; do
|
||||
if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
|
||||
if (( UDEVVERSION >= 174 )); then
|
||||
if ((UDEVVERSION >= 174)); then
|
||||
printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
|
||||
else
|
||||
printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
|
||||
fi
|
||||
elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
|
||||
if (( UDEVVERSION >= 176 )); then
|
||||
if ((UDEVVERSION >= 176)); then
|
||||
printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
|
||||
else
|
||||
# shellcheck disable=SC2016
|
||||
|
@ -588,7 +588,6 @@ inst_any() {
|
|||
return 1
|
||||
}
|
||||
|
||||
|
||||
# inst_libdir_file [-n <pattern>] <file> [<file>...]
|
||||
# Install a <file> located on a lib directory to the initramfs image
|
||||
# -n <pattern> install matching files
|
||||
|
@ -836,7 +835,8 @@ check_mount() {
|
|||
fi
|
||||
|
||||
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
|
||||
module_check_mount "$_mod" "$_moddir"; ret=$?
|
||||
module_check_mount "$_mod" "$_moddir"
|
||||
ret=$?
|
||||
|
||||
# explicit module, so also accept ret=255
|
||||
[[ $ret = 0 || $ret = 255 ]] || return 1
|
||||
|
@ -869,8 +869,8 @@ check_mount() {
|
|||
fi
|
||||
done
|
||||
|
||||
[[ " $mods_to_load " == *\ $_mod\ * ]] || \
|
||||
mods_to_load+=" $_mod "
|
||||
[[ " $mods_to_load " == *\ $_mod\ * ]] \
|
||||
|| mods_to_load+=" $_mod "
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -902,9 +902,11 @@ check_module() {
|
|||
|
||||
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
|
||||
if [[ " $dracutmodules $force_add_dracutmodules " == *\ $_mod\ * ]]; then
|
||||
module_check "$_mod" 1 "$_moddir"; ret=$?
|
||||
module_check "$_mod" 1 "$_moddir"
|
||||
ret=$?
|
||||
else
|
||||
module_check "$_mod" 0 "$_moddir"; ret=$?
|
||||
module_check "$_mod" 0 "$_moddir"
|
||||
ret=$?
|
||||
fi
|
||||
# explicit module, so also accept ret=255
|
||||
[[ $ret = 0 || $ret = 255 ]] || return 1
|
||||
|
@ -912,7 +914,8 @@ check_module() {
|
|||
# module not in our list
|
||||
if [[ $dracutmodules = all ]]; then
|
||||
# check, if we can and should install this module
|
||||
module_check "$_mod" 0 "$_moddir"; ret=$?
|
||||
module_check "$_mod" 0 "$_moddir"
|
||||
ret=$?
|
||||
if [[ $ret != 0 ]]; then
|
||||
[[ $2 ]] && return 1
|
||||
[[ $ret != 255 ]] && return 1
|
||||
|
@ -941,8 +944,8 @@ check_module() {
|
|||
fi
|
||||
done
|
||||
|
||||
[[ " $mods_to_load " == *\ $_mod\ * ]] || \
|
||||
mods_to_load+=" $_mod "
|
||||
[[ " $mods_to_load " == *\ $_mod\ * ]] \
|
||||
|| mods_to_load+=" $_mod "
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -956,10 +959,11 @@ for_each_module_dir() {
|
|||
local _func
|
||||
_func=$1
|
||||
for _moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
|
||||
[[ -d $_moddir ]] || continue;
|
||||
[[ -e $_moddir/install || -e $_moddir/installkernel || \
|
||||
-e $_moddir/module-setup.sh ]] || continue
|
||||
_mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]}
|
||||
[[ -d $_moddir ]] || continue
|
||||
[[ -e $_moddir/install || -e $_moddir/installkernel || -e \
|
||||
$_moddir/module-setup.sh ]] || continue
|
||||
_mod=${_moddir##*/}
|
||||
_mod=${_mod#[0-9][0-9]}
|
||||
$_func "$_mod" 1 "$_moddir"
|
||||
done
|
||||
|
||||
|
@ -987,8 +991,8 @@ dracut_kernel_post() {
|
|||
done
|
||||
|
||||
# generate module dependencies for the initrd
|
||||
if [[ -d $initdir/lib/modules/$kernel ]] && \
|
||||
! depmod -a -b "$initdir" "$kernel"; then
|
||||
if [[ -d $initdir/lib/modules/$kernel ]] \
|
||||
&& ! depmod -a -b "$initdir" "$kernel"; then
|
||||
dfatal "\"depmod -a $kernel\" failed."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -1041,15 +1045,15 @@ instmods() {
|
|||
if ((_ret != 0)) && [[ -z "$_silent" ]]; then
|
||||
derror "FAILED: " \
|
||||
"$DRACUT_INSTALL" \
|
||||
${initdir:+-D "$initdir"} \
|
||||
${dracutsysrootdir:+-r "$dracutsysrootdir"} \
|
||||
${loginstall:+-L "$loginstall"} \
|
||||
${hostonly:+-H} \
|
||||
${omit_drivers:+-N "$omit_drivers"} \
|
||||
${srcmods:+--kerneldir "$srcmods"} \
|
||||
${_optional:+-o} \
|
||||
${_silent:+--silent} \
|
||||
-m "$@"
|
||||
${initdir:+-D "$initdir"} \
|
||||
${dracutsysrootdir:+-r "$dracutsysrootdir"} \
|
||||
${loginstall:+-L "$loginstall"} \
|
||||
${hostonly:+-H} \
|
||||
${omit_drivers:+-N "$omit_drivers"} \
|
||||
${srcmods:+--kerneldir "$srcmods"} \
|
||||
${_optional:+-o} \
|
||||
${_silent:+--silent} \
|
||||
-m "$@"
|
||||
fi
|
||||
|
||||
[[ "$optional" ]] && return 0
|
||||
|
@ -1073,8 +1077,8 @@ is_qemu_virtualized() {
|
|||
# 0 if a virt environment was detected
|
||||
# 1 if a virt environment could not be detected
|
||||
# 255 if any error was encountered
|
||||
if type -P systemd-detect-virt >/dev/null 2>&1; then
|
||||
if ! vm=$(systemd-detect-virt --vm >/dev/null 2>&1); then
|
||||
if type -P systemd-detect-virt > /dev/null 2>&1; then
|
||||
if ! vm=$(systemd-detect-virt --vm > /dev/null 2>&1); then
|
||||
return 255
|
||||
fi
|
||||
[[ $vm = "qemu" ]] && return 0
|
||||
|
@ -1085,9 +1089,9 @@ is_qemu_virtualized() {
|
|||
for i in /sys/class/dmi/id/*_vendor; do
|
||||
[[ -f $i ]] || continue
|
||||
read -r vendor < "$i"
|
||||
[[ "$vendor" == "QEMU" ]] && return 0
|
||||
[[ "$vendor" == "QEMU" ]] && return 0
|
||||
[[ "$vendor" == "Red Hat" ]] && return 0
|
||||
[[ "$vendor" == "Bochs" ]] && return 0
|
||||
[[ "$vendor" == "Bochs" ]] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ SKIP="$dracutbasedir/skipcpio"
|
|||
|
||||
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
|
||||
|
||||
mount -o ro /boot &>/dev/null || true
|
||||
mount -o ro /boot &> /dev/null || true
|
||||
|
||||
if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \
|
||||
&& [[ $MACHINE_ID ]] \
|
||||
&& [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]] ; then
|
||||
&& [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]]; then
|
||||
IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
|
||||
elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
|
||||
&& [[ $MACHINE_ID ]] \
|
||||
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
|
||||
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then
|
||||
IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
|
||||
else
|
||||
IMG="/boot/initramfs-${KERNEL_VERSION}.img"
|
||||
|
@ -32,13 +32,13 @@ cd /run/initramfs
|
|||
|
||||
[ -f .need_shutdown -a -f "$IMG" ] || exit 1
|
||||
|
||||
if $SKIP "$IMG" | zcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then
|
||||
if $SKIP "$IMG" | zcat | cpio -id --no-absolute-filenames --quiet > /dev/null; then
|
||||
rm -f -- .need_shutdown
|
||||
elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then
|
||||
elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet > /dev/null; then
|
||||
rm -f -- .need_shutdown
|
||||
elif $SKIP "$IMG" | lz4 -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then
|
||||
elif $SKIP "$IMG" | lz4 -d -c | cpio -id --no-absolute-filenames --quiet > /dev/null; then
|
||||
rm -f -- .need_shutdown
|
||||
elif $SKIP "$IMG" | zstd -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then
|
||||
elif $SKIP "$IMG" | zstd -d -c | cpio -id --no-absolute-filenames --quiet > /dev/null; then
|
||||
rm -f -- .need_shutdown
|
||||
else
|
||||
# something failed, so we clean up
|
||||
|
@ -48,7 +48,7 @@ else
|
|||
fi
|
||||
|
||||
if [[ -d squash ]]; then
|
||||
unsquashfs -no-xattrs -f -d . squash-root.img >/dev/null
|
||||
unsquashfs -no-xattrs -f -d . squash-root.img > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Squash module is enabled for this initramfs but failed to unpack squash-root.img" >&2
|
||||
rm -f -- /run/initramfs/shutdown
|
||||
|
@ -56,7 +56,7 @@ if [[ -d squash ]]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ] ; then
|
||||
if [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ]; then
|
||||
. /etc/selinux/config
|
||||
/usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts /run/initramfs > /dev/null
|
||||
fi
|
||||
|
|
127
dracut-logger.sh
127
dracut-logger.sh
|
@ -17,10 +17,8 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
export __DRACUT_LOGGER__=1
|
||||
|
||||
|
||||
## @brief Logging facility module for dracut both at build- and boot-time.
|
||||
#
|
||||
# @section intro Introduction
|
||||
|
@ -86,7 +84,6 @@ export __DRACUT_LOGGER__=1
|
|||
#
|
||||
# @see dlog_init()
|
||||
|
||||
|
||||
## @brief Initializes dracut Logger.
|
||||
#
|
||||
# @retval 1 if something has gone wrong
|
||||
|
@ -105,7 +102,8 @@ export __DRACUT_LOGGER__=1
|
|||
# See file doc comment for details.
|
||||
dlog_init() {
|
||||
local __oldumask
|
||||
local ret=0; local errmsg
|
||||
local ret=0
|
||||
local errmsg
|
||||
[ -z "$stdloglvl" ] && stdloglvl=4
|
||||
[ -z "$sysloglvl" ] && sysloglvl=0
|
||||
[ -z "$kmsgloglvl" ] && kmsgloglvl=0
|
||||
|
@ -114,23 +112,23 @@ dlog_init() {
|
|||
|
||||
if [ -z "$fileloglvl" ]; then
|
||||
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
|
||||
elif (( fileloglvl > 0 )); then
|
||||
elif ((fileloglvl > 0)); then
|
||||
if [[ $logfile ]]; then
|
||||
__oldumask=$(umask)
|
||||
umask 0377
|
||||
! [ -e "$logfile" ] && : >"$logfile"
|
||||
! [ -e "$logfile" ] && : > "$logfile"
|
||||
umask "$__oldumask"
|
||||
if [[ -w $logfile ]] && [[ -f $logfile ]]; then
|
||||
# Mark new run in the log file
|
||||
echo >>"$logfile"
|
||||
if command -v date >/dev/null; then
|
||||
echo "=== $(date) ===" >>"$logfile"
|
||||
# Mark new run in the log file
|
||||
echo >> "$logfile"
|
||||
if command -v date > /dev/null; then
|
||||
echo "=== $(date) ===" >> "$logfile"
|
||||
else
|
||||
echo "===============================================" >>"$logfile"
|
||||
echo "===============================================" >> "$logfile"
|
||||
fi
|
||||
echo >>"$logfile"
|
||||
echo >> "$logfile"
|
||||
else
|
||||
# We cannot log to file, so turn this facility off.
|
||||
# We cannot log to file, so turn this facility off.
|
||||
fileloglvl=0
|
||||
ret=1
|
||||
errmsg="'$logfile' is not a writable file"
|
||||
|
@ -138,22 +136,22 @@ dlog_init() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if (( UID != 0 )); then
|
||||
if ((UID != 0)); then
|
||||
kmsgloglvl=0
|
||||
sysloglvl=0
|
||||
fi
|
||||
|
||||
if (( sysloglvl > 0 )); then
|
||||
if ((sysloglvl > 0)); then
|
||||
if [[ -d /run/systemd/journal ]] \
|
||||
&& type -P systemd-cat &>/dev/null \
|
||||
&& systemctl --quiet is-active systemd-journald.socket &>/dev/null \
|
||||
&& { echo "dracut-$DRACUT_VERSION" | systemd-cat -t 'dracut' &>/dev/null; } ; then
|
||||
&& type -P systemd-cat &> /dev/null \
|
||||
&& systemctl --quiet is-active systemd-journald.socket &> /dev/null \
|
||||
&& { echo "dracut-$DRACUT_VERSION" | systemd-cat -t 'dracut' &> /dev/null; }; then
|
||||
readonly _systemdcatfile="$DRACUT_TMPDIR/systemd-cat"
|
||||
mkfifo "$_systemdcatfile"
|
||||
readonly _dlogfd=15
|
||||
systemd-cat -t 'dracut' --level-prefix=true <"$_systemdcatfile" &
|
||||
exec 15>"$_systemdcatfile"
|
||||
elif ! [[ -S /dev/log ]] && [[ -w /dev/log ]] || ! command -v logger >/dev/null; then
|
||||
systemd-cat -t 'dracut' --level-prefix=true < "$_systemdcatfile" &
|
||||
exec 15> "$_systemdcatfile"
|
||||
elif ! [[ -S /dev/log ]] && [[ -w /dev/log ]] || ! command -v logger > /dev/null; then
|
||||
# We cannot log to syslog, so turn this facility off.
|
||||
kmsgloglvl=$sysloglvl
|
||||
sysloglvl=0
|
||||
|
@ -162,7 +160,7 @@ dlog_init() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if (( sysloglvl > 0 )) || (( kmsgloglvl > 0 )); then
|
||||
if ((sysloglvl > 0)) || ((kmsgloglvl > 0)); then
|
||||
if [ -n "$dracutbasedir" ]; then
|
||||
readonly syslogfacility=user
|
||||
else
|
||||
|
@ -171,44 +169,44 @@ dlog_init() {
|
|||
export syslogfacility
|
||||
fi
|
||||
|
||||
local lvl; local maxloglvl_l=0
|
||||
local lvl
|
||||
local maxloglvl_l=0
|
||||
for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
|
||||
(( lvl > maxloglvl_l )) && maxloglvl_l=$lvl
|
||||
((lvl > maxloglvl_l)) && maxloglvl_l=$lvl
|
||||
done
|
||||
readonly maxloglvl=$maxloglvl_l
|
||||
export maxloglvl
|
||||
|
||||
|
||||
if (( stdloglvl < 6 )) && ((kmsgloglvl < 6)) && ((fileloglvl < 6)) && ((sysloglvl < 6)); then
|
||||
if ((stdloglvl < 6)) && ((kmsgloglvl < 6)) && ((fileloglvl < 6)) && ((sysloglvl < 6)); then
|
||||
unset dtrace
|
||||
dtrace() { :; };
|
||||
dtrace() { :; }
|
||||
fi
|
||||
|
||||
if ((stdloglvl < 5)) && ((kmsgloglvl < 5)) && ((fileloglvl < 5)) && ((sysloglvl < 5)); then
|
||||
unset ddebug
|
||||
ddebug() { :; };
|
||||
ddebug() { :; }
|
||||
fi
|
||||
|
||||
if ((stdloglvl < 4)) && ((kmsgloglvl < 4)) && ((fileloglvl < 4)) && ((sysloglvl < 4)); then
|
||||
unset dinfo
|
||||
dinfo() { :; };
|
||||
dinfo() { :; }
|
||||
fi
|
||||
|
||||
if ((stdloglvl < 3)) && ((kmsgloglvl < 3)) && ((fileloglvl < 3)) && ((sysloglvl < 3)); then
|
||||
unset dwarn
|
||||
dwarn() { :; };
|
||||
dwarn() { :; }
|
||||
unset dwarning
|
||||
dwarning() { :; };
|
||||
dwarning() { :; }
|
||||
fi
|
||||
|
||||
if ((stdloglvl < 2)) && ((kmsgloglvl < 2)) && ((fileloglvl < 2)) && ((sysloglvl < 2)); then
|
||||
unset derror
|
||||
derror() { :; };
|
||||
derror() { :; }
|
||||
fi
|
||||
|
||||
if ((stdloglvl < 1)) && ((kmsgloglvl < 1)) && ((fileloglvl < 1)) && ((sysloglvl < 1)); then
|
||||
unset dfatal
|
||||
dfatal() { :; };
|
||||
dfatal() { :; }
|
||||
fi
|
||||
|
||||
[ -n "$errmsg" ] && derror "$errmsg"
|
||||
|
@ -224,13 +222,13 @@ dlog_init() {
|
|||
# @result Echoes first letter of level name.
|
||||
_lvl2char() {
|
||||
case "$1" in
|
||||
1) echo F;;
|
||||
2) echo E;;
|
||||
3) echo W;;
|
||||
4) echo I;;
|
||||
5) echo D;;
|
||||
6) echo T;;
|
||||
*) return 1;;
|
||||
1) echo F ;;
|
||||
2) echo E ;;
|
||||
3) echo W ;;
|
||||
4) echo I ;;
|
||||
5) echo D ;;
|
||||
6) echo T ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -243,13 +241,13 @@ _lvl2char() {
|
|||
_lvl2syspri() {
|
||||
printf "%s" -- "$syslogfacility."
|
||||
case "$1" in
|
||||
1) echo crit;;
|
||||
2) echo error;;
|
||||
3) echo warning;;
|
||||
4) echo info;;
|
||||
5) echo debug;;
|
||||
6) echo debug;;
|
||||
*) return 1;;
|
||||
1) echo crit ;;
|
||||
2) echo error ;;
|
||||
3) echo warning ;;
|
||||
4) echo info ;;
|
||||
5) echo debug ;;
|
||||
6) echo debug ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -279,16 +277,16 @@ _dlvl2syslvl() {
|
|||
local lvl
|
||||
|
||||
case "$1" in
|
||||
1) lvl=2;;
|
||||
2) lvl=3;;
|
||||
3) lvl=4;;
|
||||
4) lvl=6;;
|
||||
5) lvl=7;;
|
||||
6) lvl=7;;
|
||||
*) return 1;;
|
||||
1) lvl=2 ;;
|
||||
2) lvl=3 ;;
|
||||
3) lvl=4 ;;
|
||||
4) lvl=6 ;;
|
||||
5) lvl=7 ;;
|
||||
6) lvl=7 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
|
||||
[ "$syslogfacility" = user ] && echo $(( 8 + lvl )) || echo $(( 24 + lvl ))
|
||||
[ "$syslogfacility" = user ] && echo $((8 + lvl)) || echo $((24 + lvl))
|
||||
}
|
||||
|
||||
## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg
|
||||
|
@ -318,14 +316,15 @@ _dlvl2syslvl() {
|
|||
# - @c INFO to @c info
|
||||
# - @c DEBUG and @c TRACE both to @c debug
|
||||
_do_dlog() {
|
||||
local lvl="$1"; shift
|
||||
local lvl="$1"
|
||||
shift
|
||||
local lvlc=$(_lvl2char "$lvl") || return 0
|
||||
local msg="$*"
|
||||
local lmsg="$lvlc: $*"
|
||||
|
||||
(( lvl <= stdloglvl )) && printf -- 'dracut: %s\n' "$msg" >&2
|
||||
((lvl <= stdloglvl)) && printf -- 'dracut: %s\n' "$msg" >&2
|
||||
|
||||
if (( lvl <= sysloglvl )); then
|
||||
if ((lvl <= sysloglvl)); then
|
||||
if [[ "$_dlogfd" ]]; then
|
||||
printf -- "<%s>%s\n" "$(($(_dlvl2syslvl "$lvl") & 7))" "$msg" >&$_dlogfd
|
||||
else
|
||||
|
@ -333,12 +332,12 @@ _do_dlog() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if (( lvl <= fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
|
||||
echo "$lmsg" >>"$logfile"
|
||||
if ((lvl <= fileloglvl)) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
|
||||
echo "$lmsg" >> "$logfile"
|
||||
fi
|
||||
|
||||
(( lvl <= kmsgloglvl )) && \
|
||||
echo "<$(_dlvl2syslvl "$lvl")>dracut[$$] $msg" >/dev/kmsg
|
||||
((lvl <= kmsgloglvl)) \
|
||||
&& echo "<$(_dlvl2syslvl "$lvl")>dracut[$$] $msg" > /dev/kmsg
|
||||
}
|
||||
|
||||
## @brief Internal helper function for _do_dlog()
|
||||
|
@ -359,9 +358,9 @@ _do_dlog() {
|
|||
# echo "This is a warning" | dwarn
|
||||
dlog() {
|
||||
[ -z "$maxloglvl" ] && return 0
|
||||
(( $1 <= maxloglvl )) || return 0
|
||||
(($1 <= maxloglvl)) || return 0
|
||||
|
||||
if (( $# > 1 )); then
|
||||
if (($# > 1)); then
|
||||
_do_dlog "$@"
|
||||
else
|
||||
while read -r line || [ -n "$line" ]; do
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
set -e
|
||||
|
||||
if [[ -z "$DRACUT_TMPDIR" ]]; then
|
||||
echo "DRACUT_TMPDIR is unset, exiting"
|
||||
exit 0
|
||||
echo "DRACUT_TMPDIR is unset, exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# We have to unset "prefix" as dracut uses it to move files around.
|
||||
|
@ -21,11 +21,11 @@ export DRACUT_INSTALL_PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
|||
export PLYMOUTH_SYSROOT=$D
|
||||
|
||||
export \
|
||||
systemdutildir systemdsystemunitdir systemdsystemconfdir udevdir \
|
||||
DRACUT_ARCH DRACUT_TESTBIN DRACUT_LDD DRACUT_LDCONFIG DRACUT_INSTALL \
|
||||
DRACUT_COMPRESS_GZIP DRACUT_COMPRESS_BZIP2 DRACUT_COMPRESS_LZMA \
|
||||
PLYMOUTH_LDD PLYMOUTH_LDD_PATH PLYMOUTH_PLUGIN_PATH \
|
||||
PLYMOUTH_THEME_NAME PLYMOUTH_THEME
|
||||
systemdutildir systemdsystemunitdir systemdsystemconfdir udevdir \
|
||||
DRACUT_ARCH DRACUT_TESTBIN DRACUT_LDD DRACUT_LDCONFIG DRACUT_INSTALL \
|
||||
DRACUT_COMPRESS_GZIP DRACUT_COMPRESS_BZIP2 DRACUT_COMPRESS_LZMA \
|
||||
PLYMOUTH_LDD PLYMOUTH_LDD_PATH PLYMOUTH_PLUGIN_PATH \
|
||||
PLYMOUTH_THEME_NAME PLYMOUTH_THEME
|
||||
|
||||
# List environment for debugging
|
||||
echo ROOTFS-POSTINST-ENVIRONMENT
|
||||
|
|
|
@ -35,11 +35,11 @@ else
|
|||
cd test
|
||||
|
||||
time LOGTEE_TIMEOUT_MS=590000 make \
|
||||
enable_documentation=$make_docs \
|
||||
KVERSION="$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1)" \
|
||||
DRACUT_NO_XATTR=1 \
|
||||
TEST_RUN_ID="$RUN_ID" \
|
||||
${TESTS:+TESTS="$TESTS"} \
|
||||
-k V=1 \
|
||||
check
|
||||
enable_documentation=$make_docs \
|
||||
KVERSION="$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1)" \
|
||||
DRACUT_NO_XATTR=1 \
|
||||
TEST_RUN_ID="$RUN_ID" \
|
||||
${TESTS:+TESTS="$TESTS"} \
|
||||
-k V=1 \
|
||||
check
|
||||
fi
|
||||
|
|
|
@ -20,11 +20,11 @@ else
|
|||
cd test
|
||||
|
||||
time sudo LOGTEE_TIMEOUT_MS=300000 make \
|
||||
enable_documentation=$make_docs \
|
||||
KVERSION=$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1) \
|
||||
DRACUT_NO_XATTR=1 \
|
||||
TEST_RUN_ID=$RUN_ID \
|
||||
${TESTS:+TESTS="$TESTS"} \
|
||||
-k V=2 \
|
||||
check
|
||||
enable_documentation=$make_docs \
|
||||
KVERSION=$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1) \
|
||||
DRACUT_NO_XATTR=1 \
|
||||
TEST_RUN_ID=$RUN_ID \
|
||||
${TESTS:+TESTS="$TESTS"} \
|
||||
-k V=2 \
|
||||
check
|
||||
fi
|
||||
|
|
|
@ -15,53 +15,57 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__contains_word () {
|
||||
local word="$1"; shift
|
||||
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
|
||||
return 1
|
||||
__contains_word() {
|
||||
local word="$1"
|
||||
shift
|
||||
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
_lsinitrd() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-s --size -h --help'
|
||||
[ARG]='-f --file -k --kver'
|
||||
)
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD - 1]}
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-s --size -h --help'
|
||||
[ARG]='-f --file -k --kver'
|
||||
)
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--file|-f)
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
--kver|-k)
|
||||
comps=$(cd /lib/modules || return 1; echo [0-9]*)
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
# shellcheck disable=SC2086
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--file | -f)
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
--kver | -k)
|
||||
comps=$(
|
||||
cd /lib/modules || return 1
|
||||
echo [0-9]*
|
||||
)
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $cur = -* ]]; then
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
esac
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
COMPREPLY=($(compgen -W '$comps' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $cur = -* ]]; then
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=($(compgen -W '${OPTS[*]}' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
# shellcheck disable=SC2207
|
||||
# shellcheck disable=SC2016
|
||||
COMPREPLY=($(compgen -W '$comps' -- "$cur"))
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _lsinitrd lsinitrd
|
||||
|
|
137
lsinitrd.sh
137
lsinitrd.sh
|
@ -17,8 +17,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
usage()
|
||||
{
|
||||
usage() {
|
||||
{
|
||||
echo "Usage: ${0##*/} [options] [<initramfs file> [<filename> [<filename> [...] ]]]"
|
||||
echo "Usage: ${0##*/} [options] -k <kernel version>"
|
||||
|
@ -38,7 +37,6 @@ usage()
|
|||
} >&2
|
||||
}
|
||||
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
|
||||
sorted=0
|
||||
|
@ -59,7 +57,7 @@ TEMP=$(getopt \
|
|||
--long verbose \
|
||||
-- "$@")
|
||||
|
||||
if (( $? != 0 )); then
|
||||
if (($? != 0)); then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
@ -68,16 +66,31 @@ eval set -- "$TEMP"
|
|||
|
||||
while (($# > 0)); do
|
||||
case $1 in
|
||||
-k|--kver) KERNEL_VERSION="$2"; shift;;
|
||||
-f|--file) filenames[${2#/}]=1; shift;;
|
||||
-s|--size) sorted=1;;
|
||||
-h|--help) usage; exit 0;;
|
||||
-m|--mod) modules=1;;
|
||||
-v|--verbose) verbose="--verbose";;
|
||||
--unpack) unpack=1;;
|
||||
--unpackearly) unpackearly=1;;
|
||||
--) shift;break;;
|
||||
*) usage; exit 1;;
|
||||
-k | --kver)
|
||||
KERNEL_VERSION="$2"
|
||||
shift
|
||||
;;
|
||||
-f | --file)
|
||||
filenames[${2#/}]=1
|
||||
shift
|
||||
;;
|
||||
-s | --size) sorted=1 ;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-m | --mod) modules=1 ;;
|
||||
-v | --verbose) verbose="--verbose" ;;
|
||||
--unpack) unpack=1 ;;
|
||||
--unpackearly) unpackearly=1 ;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -99,11 +112,11 @@ else
|
|||
|
||||
if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \
|
||||
&& [[ $MACHINE_ID ]] \
|
||||
&& [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]] ; then
|
||||
&& [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]]; then
|
||||
image="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
|
||||
elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
|
||||
&& [[ $MACHINE_ID ]] \
|
||||
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
|
||||
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then
|
||||
image="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
|
||||
else
|
||||
image="/boot/initramfs-${KERNEL_VERSION}.img"
|
||||
|
@ -112,7 +125,7 @@ fi
|
|||
|
||||
shift
|
||||
while (($# > 0)); do
|
||||
filenames[${1#/}]=1;
|
||||
filenames[${1#/}]=1
|
||||
shift
|
||||
done
|
||||
|
||||
|
@ -134,46 +147,42 @@ dracutlibdirs() {
|
|||
done
|
||||
}
|
||||
|
||||
extract_files()
|
||||
{
|
||||
(( ${#filenames[@]} == 1 )) && nofileinfo=1
|
||||
extract_files() {
|
||||
((${#filenames[@]} == 1)) && nofileinfo=1
|
||||
for f in "${!filenames[@]}"; do
|
||||
[[ $nofileinfo ]] || echo "initramfs:/$f"
|
||||
[[ $nofileinfo ]] || echo "========================================================================"
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout "$f" 2>/dev/null
|
||||
((ret+=$?))
|
||||
$CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --to-stdout "$f" 2> /dev/null
|
||||
((ret += $?))
|
||||
[[ $nofileinfo ]] || echo "========================================================================"
|
||||
[[ $nofileinfo ]] || echo
|
||||
done
|
||||
}
|
||||
|
||||
list_modules()
|
||||
{
|
||||
list_modules() {
|
||||
echo "dracut modules:"
|
||||
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- \
|
||||
$(dracutlibdirs modules.txt) 2>/dev/null
|
||||
((ret+=$?))
|
||||
$(dracutlibdirs modules.txt) 2> /dev/null
|
||||
((ret += $?))
|
||||
}
|
||||
|
||||
list_files()
|
||||
{
|
||||
list_files() {
|
||||
echo "========================================================================"
|
||||
if [ "$sorted" -eq 1 ]; then
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --list | sort -n -k5
|
||||
$CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --list | sort -n -k5
|
||||
else
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --list | sort -k9
|
||||
$CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --list | sort -k9
|
||||
fi
|
||||
((ret+=$?))
|
||||
((ret += $?))
|
||||
echo "========================================================================"
|
||||
}
|
||||
|
||||
list_squash_content()
|
||||
{
|
||||
list_squash_content() {
|
||||
SQUASH_IMG="squash-root.img"
|
||||
SQUASH_TMPFILE="$TMPDIR/initrd.root.sqsh"
|
||||
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout -- \
|
||||
$SQUASH_IMG > "$SQUASH_TMPFILE" 2>/dev/null
|
||||
$CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --to-stdout -- \
|
||||
$SQUASH_IMG > "$SQUASH_TMPFILE" 2> /dev/null
|
||||
if [[ -s $SQUASH_TMPFILE ]]; then
|
||||
echo "Squashed content ($SQUASH_IMG):"
|
||||
echo "========================================================================"
|
||||
|
@ -182,22 +191,24 @@ list_squash_content()
|
|||
fi
|
||||
}
|
||||
|
||||
unpack_files()
|
||||
{
|
||||
if (( ${#filenames[@]} > 0 )); then
|
||||
unpack_files() {
|
||||
if ((${#filenames[@]} > 0)); then
|
||||
for f in "${!filenames[@]}"; do
|
||||
$CAT "$image" 2>/dev/null | cpio -id --quiet $verbose $f
|
||||
((ret+=$?))
|
||||
$CAT "$image" 2> /dev/null | cpio -id --quiet $verbose $f
|
||||
((ret += $?))
|
||||
done
|
||||
else
|
||||
$CAT "$image" 2>/dev/null | cpio -id --quiet $verbose
|
||||
((ret+=$?))
|
||||
$CAT "$image" 2> /dev/null | cpio -id --quiet $verbose
|
||||
((ret += $?))
|
||||
fi
|
||||
}
|
||||
|
||||
read -N 2 bin < "$image"
|
||||
if [ "$bin" = "MZ" ]; then
|
||||
command -v objcopy > /dev/null || { echo "Need 'objcopy' to unpack an UEFI executable."; exit 1; }
|
||||
command -v objcopy > /dev/null || {
|
||||
echo "Need 'objcopy' to unpack an UEFI executable."
|
||||
exit 1
|
||||
}
|
||||
objcopy \
|
||||
--dump-section .linux="$TMPDIR/vmlinuz" \
|
||||
--dump-section .initrd="$TMPDIR/initrd.img" \
|
||||
|
@ -209,10 +220,10 @@ if [ "$bin" = "MZ" ]; then
|
|||
[ -f "$image" ] || exit 1
|
||||
fi
|
||||
|
||||
if (( ${#filenames[@]} <= 0 )) && [[ -z "$unpack" ]] && [[ -z "$unpackearly" ]]; then
|
||||
if ((${#filenames[@]} <= 0)) && [[ -z "$unpack" ]] && [[ -z "$unpackearly" ]]; then
|
||||
if [ -n "$uefi" ]; then
|
||||
echo -n "initrd in UEFI: $uefi: "
|
||||
du -h $image | while read a b || [ -n "$a" ]; do echo $a;done
|
||||
du -h $image | while read a b || [ -n "$a" ]; do echo $a; done
|
||||
if [ -f "$TMPDIR/osrel.txt" ]; then
|
||||
name=$(sed -En '/^PRETTY_NAME/ s/^\w+=["'"'"']?([^"'"'"'$]*)["'"'"']?/\1/p' "$TMPDIR/osrel.txt")
|
||||
id=$(sed -En '/^ID/ s/^\w+=["'"'"']?([^"'"'"'$]*)["'"'"']?/\1/p' "$TMPDIR/osrel.txt")
|
||||
|
@ -229,7 +240,7 @@ if (( ${#filenames[@]} <= 0 )) && [[ -z "$unpack" ]] && [[ -z "$unpackearly" ]];
|
|||
fi
|
||||
else
|
||||
echo -n "Image: $image: "
|
||||
du -h $image | while read a b || [ -n "$a" ]; do echo $a;done
|
||||
du -h $image | while read a b || [ -n "$a" ]; do echo $a; done
|
||||
fi
|
||||
|
||||
echo "========================================================================"
|
||||
|
@ -237,18 +248,18 @@ fi
|
|||
|
||||
read -N 6 bin < "$image"
|
||||
case $bin in
|
||||
$'\x71\xc7'*|070701)
|
||||
$'\x71\xc7'* | 070701)
|
||||
CAT="cat --"
|
||||
is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2>/dev/null)
|
||||
is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2> /dev/null)
|
||||
# Debian mkinitramfs does not create the file 'early_cpio', so let's check if firmware files exist
|
||||
[[ "$is_early" ]] || is_early=$(cpio --list --verbose --quiet --to-stdout -- 'kernel/*/microcode/*.bin' < "$image" 2>/dev/null)
|
||||
[[ "$is_early" ]] || is_early=$(cpio --list --verbose --quiet --to-stdout -- 'kernel/*/microcode/*.bin' < "$image" 2> /dev/null)
|
||||
if [[ "$is_early" ]]; then
|
||||
if [[ -n "$unpack" ]]; then
|
||||
# should use --unpackearly for early CPIO
|
||||
:
|
||||
elif [[ -n "$unpackearly" ]]; then
|
||||
unpack_files
|
||||
elif (( ${#filenames[@]} > 0 )); then
|
||||
elif ((${#filenames[@]} > 0)); then
|
||||
extract_files
|
||||
else
|
||||
echo "Early CPIO image"
|
||||
|
@ -269,8 +280,8 @@ case $bin in
|
|||
;;
|
||||
esac
|
||||
|
||||
if [[ $SKIP ]] ; then
|
||||
bin="$($SKIP "$image" | { read -N 6 bin && echo "$bin" ; })"
|
||||
if [[ $SKIP ]]; then
|
||||
bin="$($SKIP "$image" | { read -N 6 bin && echo "$bin"; })"
|
||||
else
|
||||
read -N 6 bin < "$image"
|
||||
fi
|
||||
|
@ -281,7 +292,7 @@ case $bin in
|
|||
BZh*)
|
||||
CAT="bzcat --"
|
||||
;;
|
||||
$'\x71\xc7'*|070701)
|
||||
$'\x71\xc7'* | 070701)
|
||||
CAT="cat --"
|
||||
;;
|
||||
$'\x02\x21'*)
|
||||
|
@ -294,7 +305,7 @@ case $bin in
|
|||
CAT="zstd -d -c"
|
||||
;;
|
||||
*)
|
||||
if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
|
||||
if echo "test" | xz | xzcat --single-stream > /dev/null 2>&1; then
|
||||
CAT="xzcat --single-stream --"
|
||||
else
|
||||
CAT="xzcat --"
|
||||
|
@ -302,8 +313,7 @@ case $bin in
|
|||
;;
|
||||
esac
|
||||
|
||||
skipcpio()
|
||||
{
|
||||
skipcpio() {
|
||||
$SKIP "$@" | $ORIG_CAT
|
||||
}
|
||||
|
||||
|
@ -312,11 +322,10 @@ if [[ $SKIP ]]; then
|
|||
CAT=skipcpio
|
||||
fi
|
||||
|
||||
if (( ${#filenames[@]} > 1 )); then
|
||||
if ((${#filenames[@]} > 1)); then
|
||||
TMPFILE="$TMPDIR/initrd.cpio"
|
||||
$CAT "$image" 2>/dev/null > $TMPFILE
|
||||
pre_decompress()
|
||||
{
|
||||
$CAT "$image" 2> /dev/null > $TMPFILE
|
||||
pre_decompress() {
|
||||
cat $TMPFILE
|
||||
}
|
||||
CAT=pre_decompress
|
||||
|
@ -326,12 +335,12 @@ ret=0
|
|||
|
||||
if [[ -n "$unpack" ]]; then
|
||||
unpack_files
|
||||
elif (( ${#filenames[@]} > 0 )); then
|
||||
elif ((${#filenames[@]} > 0)); then
|
||||
extract_files
|
||||
else
|
||||
version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- \
|
||||
$(dracutlibdirs 'dracut-*') 2>/dev/null)
|
||||
((ret+=$?))
|
||||
$(dracutlibdirs 'dracut-*') 2> /dev/null)
|
||||
((ret += $?))
|
||||
echo "Version: $version"
|
||||
echo
|
||||
if [ "$modules" -eq 1 ]; then
|
||||
|
@ -340,7 +349,7 @@ else
|
|||
else
|
||||
echo -n "Arguments: "
|
||||
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- \
|
||||
$(dracutlibdirs build-parameter.txt) 2>/dev/null
|
||||
$(dracutlibdirs build-parameter.txt) 2> /dev/null
|
||||
echo
|
||||
list_modules
|
||||
list_files
|
||||
|
|
|
@ -8,7 +8,7 @@ force=0
|
|||
|
||||
error() { echo "$@" >&2; }
|
||||
|
||||
usage () {
|
||||
usage() {
|
||||
[[ $1 = '-n' ]] && cmd=echo || cmd=error
|
||||
|
||||
$cmd "usage: ${0##*/} [--version] [--help] [-v] [-f] [--preload <module>]"
|
||||
|
@ -34,16 +34,16 @@ read_arg() {
|
|||
if [[ $2 =~ $rematch ]]; then
|
||||
read "$param" <<< "${BASH_REMATCH[1]}"
|
||||
else
|
||||
for ((i=3; $i <= $#; i++)); do
|
||||
for ((i = 3; $i <= $#; i++)); do
|
||||
# Only read next arg if it not an arg itself.
|
||||
if [[ ${*:$i:1} = -* ]];then
|
||||
break
|
||||
if [[ ${*:$i:1} = -* ]]; then
|
||||
break
|
||||
fi
|
||||
result="$result ${@:$i:1}"
|
||||
# There is no way to shift our callers args, so
|
||||
# return "no of args" to indicate they should do it instead.
|
||||
done
|
||||
read "$1" <<< "$result"
|
||||
done
|
||||
read "$1" <<< "$result"
|
||||
return $(($i - 3))
|
||||
fi
|
||||
}
|
||||
|
@ -54,35 +54,36 @@ default_kernel_images() {
|
|||
local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
|
||||
|
||||
case "${DRACUT_ARCH:-$(uname -m)}" in
|
||||
s390|s390x)
|
||||
s390 | s390x)
|
||||
regex='image'
|
||||
;;
|
||||
ppc*)
|
||||
regex='vmlinux'
|
||||
;;
|
||||
i?86|x86_64)
|
||||
i?86 | x86_64)
|
||||
regex='vmlinuz'
|
||||
;;
|
||||
arm*)
|
||||
regex='[uz]Image'
|
||||
;;
|
||||
aarch64|riscv64)
|
||||
aarch64 | riscv64)
|
||||
regex='Image'
|
||||
;;
|
||||
*) regex='vmlinu.'
|
||||
*)
|
||||
regex='vmlinu.'
|
||||
;;
|
||||
esac
|
||||
|
||||
# user mode linux
|
||||
if grep -q UML /proc/cpuinfo; then
|
||||
regex='linux'
|
||||
regex='linux'
|
||||
fi
|
||||
|
||||
kernel_images=""
|
||||
initrd_images=""
|
||||
for kernel_image in $(ls $boot_dir \
|
||||
| sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
|
||||
| grep -v kdump$ ) ; do
|
||||
| sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
|
||||
| grep -v kdump$); do
|
||||
|
||||
# Note that we cannot check the RPM database here -- this
|
||||
# script is itself called from within the binary kernel
|
||||
|
@ -91,20 +92,20 @@ default_kernel_images() {
|
|||
[ -L "$boot_dir/$kernel_image" ] && continue
|
||||
[ "${kernel_image%%.gz}" != "$kernel_image" ] && continue
|
||||
kernel_version=$(/usr/bin/get_kernel_version \
|
||||
$boot_dir/$kernel_image 2> /dev/null)
|
||||
$boot_dir/$kernel_image 2> /dev/null)
|
||||
initrd_image=$(echo $kernel_image | sed -e "s|${regex}|initrd|")
|
||||
if [ "$kernel_image" != "$initrd_image" -a \
|
||||
-n "$kernel_version" -a \
|
||||
-d "/lib/modules/$kernel_version" ]; then
|
||||
kernel_images="$kernel_images $boot_dir/$kernel_image"
|
||||
initrd_images="$initrd_images $boot_dir/$initrd_image"
|
||||
-n "$kernel_version" -a \
|
||||
-d "/lib/modules/$kernel_version" ]; then
|
||||
kernel_images="$kernel_images $boot_dir/$kernel_image"
|
||||
initrd_images="$initrd_images $boot_dir/$initrd_image"
|
||||
fi
|
||||
done
|
||||
for kernel_image in $kernel_images;do
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
for kernel_image in $kernel_images; do
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
done
|
||||
for initrd_image in $initrd_images;do
|
||||
targets="$targets $initrd_image"
|
||||
for initrd_image in $initrd_images; do
|
||||
targets="$targets $initrd_image"
|
||||
done
|
||||
host_only=1
|
||||
force=1
|
||||
|
@ -112,25 +113,36 @@ default_kernel_images() {
|
|||
|
||||
while (($# > 0)); do
|
||||
case ${1%%=*} in
|
||||
--with-usb) read_arg usbmodule "$@" || shift $?
|
||||
--with-usb)
|
||||
read_arg usbmodule "$@" || shift $?
|
||||
basicmodules="$basicmodules ${usbmodule:-usb-storage}"
|
||||
unset usbmodule;;
|
||||
--with-avail) read_arg modname "$@" || shift $?
|
||||
basicmodules="$basicmodules $modname";;
|
||||
--with) read_arg modname "$@" || shift $?
|
||||
basicmodules="$basicmodules $modname";;
|
||||
unset usbmodule
|
||||
;;
|
||||
--with-avail)
|
||||
read_arg modname "$@" || shift $?
|
||||
basicmodules="$basicmodules $modname"
|
||||
;;
|
||||
--with)
|
||||
read_arg modname "$@" || shift $?
|
||||
basicmodules="$basicmodules $modname"
|
||||
;;
|
||||
--version)
|
||||
echo "mkinitrd: dracut compatibility wrapper"
|
||||
exit 0;;
|
||||
-v|--verbose) dracut_args="${dracut_args} -v";;
|
||||
-f|--force) force=1;;
|
||||
--preload) read_arg modname "$@" || shift $?
|
||||
basicmodules="$basicmodules $modname";;
|
||||
--image-version) img_vers=yes;;
|
||||
--rootfs|-d) read_arg rootfs "$@" || shift $?
|
||||
dracut_args="${dracut_args} --filesystems $rootfs";;
|
||||
--nocompress) dracut_args="$dracut_args --no-compress";;
|
||||
--help) usage -n;;
|
||||
exit 0
|
||||
;;
|
||||
-v | --verbose) dracut_args="${dracut_args} -v" ;;
|
||||
-f | --force) force=1 ;;
|
||||
--preload)
|
||||
read_arg modname "$@" || shift $?
|
||||
basicmodules="$basicmodules $modname"
|
||||
;;
|
||||
--image-version) img_vers=yes ;;
|
||||
--rootfs | -d)
|
||||
read_arg rootfs "$@" || shift $?
|
||||
dracut_args="${dracut_args} --filesystems $rootfs"
|
||||
;;
|
||||
--nocompress) dracut_args="$dracut_args --no-compress" ;;
|
||||
--help) usage -n ;;
|
||||
--builtin) ;;
|
||||
--without*) ;;
|
||||
--without-usb) ;;
|
||||
|
@ -153,34 +165,36 @@ while (($# > 0)); do
|
|||
--loopopts*) ;;
|
||||
--looppath*) ;;
|
||||
--dsdt*) ;;
|
||||
-s) ;;
|
||||
--quiet|-q) quiet=1;;
|
||||
-b) read_arg boot_dir "$@" || shift $?
|
||||
if [ ! -d $boot_dir ];then
|
||||
error "Boot directory $boot_dir does not exist"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-k) # Would be nice to get a list of images here
|
||||
read_arg kernel_images "$@" || shift $?
|
||||
for kernel_image in $kernel_images;do
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
done
|
||||
host_only=1
|
||||
force=1
|
||||
;;
|
||||
-i) read_arg initrd_images "$@" || shift $?
|
||||
for initrd_image in $initrd_images;do
|
||||
targets="$targets $boot_dir/$initrd_image"
|
||||
done
|
||||
;;
|
||||
*) if [[ ! $targets ]]; then
|
||||
-s) ;;
|
||||
--quiet | -q) quiet=1 ;;
|
||||
-b)
|
||||
read_arg boot_dir "$@" || shift $?
|
||||
if [ ! -d $boot_dir ]; then
|
||||
error "Boot directory $boot_dir does not exist"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-k) # Would be nice to get a list of images here
|
||||
read_arg kernel_images "$@" || shift $?
|
||||
for kernel_image in $kernel_images; do
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
done
|
||||
host_only=1
|
||||
force=1
|
||||
;;
|
||||
-i)
|
||||
read_arg initrd_images "$@" || shift $?
|
||||
for initrd_image in $initrd_images; do
|
||||
targets="$targets $boot_dir/$initrd_image"
|
||||
done
|
||||
;;
|
||||
*) if [[ ! $targets ]]; then
|
||||
targets=$1
|
||||
elif [[ ! $kernels ]]; then
|
||||
elif [[ ! $kernels ]]; then
|
||||
kernels=$1
|
||||
else
|
||||
else
|
||||
usage
|
||||
fi;;
|
||||
fi ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -189,37 +203,37 @@ done
|
|||
[[ $targets && $kernels ]] || (error "No kernel found in $boot_dir" && usage)
|
||||
|
||||
# We can have several targets/kernels, transform the list to an array
|
||||
targets=( $targets )
|
||||
[[ $kernels ]] && kernels=( $kernels )
|
||||
targets=($targets)
|
||||
[[ $kernels ]] && kernels=($kernels)
|
||||
|
||||
[[ $host_only == 1 ]] && dracut_args="${dracut_args} -H"
|
||||
[[ $force == 1 ]] && dracut_args="${dracut_args} -f"
|
||||
[[ $force == 1 ]] && dracut_args="${dracut_args} -f"
|
||||
|
||||
echo "Creating: target|kernel|dracut args|basicmodules "
|
||||
for ((i=0 ; $i<${#targets[@]} ; i++)); do
|
||||
for ((i = 0; $i < ${#targets[@]}; i++)); do
|
||||
|
||||
if [[ $img_vers ]];then
|
||||
target="${targets[$i]}-${kernels[$i]}"
|
||||
if [[ $img_vers ]]; then
|
||||
target="${targets[$i]}-${kernels[$i]}"
|
||||
else
|
||||
target="${targets[$i]}"
|
||||
target="${targets[$i]}"
|
||||
fi
|
||||
kernel="${kernels[$i]}"
|
||||
|
||||
# Duplicate code: No way found how to redirect output based on $quiet
|
||||
if [[ $quiet == 1 ]];then
|
||||
echo "$target|$kernel|$dracut_args|$basicmodules"
|
||||
if [[ $basicmodules ]]; then
|
||||
if [[ $quiet == 1 ]]; then
|
||||
echo "$target|$kernel|$dracut_args|$basicmodules"
|
||||
if [[ $basicmodules ]]; then
|
||||
dracut $dracut_args --add-drivers "$basicmodules" "$target" \
|
||||
"$kernel" &>/dev/null
|
||||
else
|
||||
dracut $dracut_args "$target" "$kernel" &>/dev/null
|
||||
fi
|
||||
"$kernel" &> /dev/null
|
||||
else
|
||||
dracut $dracut_args "$target" "$kernel" &> /dev/null
|
||||
fi
|
||||
else
|
||||
if [[ $basicmodules ]]; then
|
||||
if [[ $basicmodules ]]; then
|
||||
dracut $dracut_args --add-drivers "$basicmodules" "$target" \
|
||||
"$kernel"
|
||||
else
|
||||
"$kernel"
|
||||
else
|
||||
dracut $dracut_args "$target" "$kernel"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
253
mkinitrd-suse.sh
253
mkinitrd-suse.sh
|
@ -25,7 +25,7 @@ dracut_cmd=dracut
|
|||
|
||||
error() { echo "$@" >&2; }
|
||||
|
||||
usage () {
|
||||
usage() {
|
||||
[[ $1 = '-n' ]] && cmd=echo || cmd=error
|
||||
|
||||
$cmd "usage: ${0##*/} [options]"
|
||||
|
@ -85,16 +85,16 @@ read_arg() {
|
|||
if [[ $2 =~ $rematch ]]; then
|
||||
read "$param" <<< "${BASH_REMATCH[1]}"
|
||||
else
|
||||
for ((i=3; $i <= $#; i++)); do
|
||||
for ((i = 3; $i <= $#; i++)); do
|
||||
# Only read next arg if it not an arg itself.
|
||||
if [[ ${*:$i:1} = -* ]];then
|
||||
break
|
||||
if [[ ${*:$i:1} = -* ]]; then
|
||||
break
|
||||
fi
|
||||
result="$result ${@:$i:1}"
|
||||
# There is no way to shift our callers args, so
|
||||
# return "no of args" to indicate they should do it instead.
|
||||
done
|
||||
read "$1" <<< "$result"
|
||||
done
|
||||
read "$1" <<< "$result"
|
||||
return $(($i - 3))
|
||||
fi
|
||||
}
|
||||
|
@ -104,12 +104,12 @@ calc_netmask() {
|
|||
local prefix=$1
|
||||
|
||||
[ -z "$prefix" ] && return
|
||||
mask=$(( 0xffffffff << (32 - $prefix) ))
|
||||
byte1=$(( mask >> 24 ))
|
||||
byte2=$(( mask >> 16 ))
|
||||
byte3=$(( mask >> 8 ))
|
||||
byte4=$(( mask & 0xff ))
|
||||
netmask=$(printf "%d.%d.%d.%d" $(( byte1 & 0xff )) $(( byte2 & 0xff )) $(( byte3 & 0xff )) $byte4);
|
||||
mask=$((0xffffffff << (32 - $prefix)))
|
||||
byte1=$((mask >> 24))
|
||||
byte2=$((mask >> 16))
|
||||
byte3=$((mask >> 8))
|
||||
byte4=$((mask & 0xff))
|
||||
netmask=$(printf "%d.%d.%d.%d" $((byte1 & 0xff)) $((byte2 & 0xff)) $((byte3 & 0xff)) $byte4)
|
||||
|
||||
echo $netmask
|
||||
}
|
||||
|
@ -135,8 +135,7 @@ is_xen_kernel() {
|
|||
local root_dir=$2
|
||||
local cfg
|
||||
|
||||
for cfg in ${root_dir}/boot/config-$kversion $root_dir/lib/modules/$kversion/build/.config
|
||||
do
|
||||
for cfg in ${root_dir}/boot/config-$kversion $root_dir/lib/modules/$kversion/build/.config; do
|
||||
test -r $cfg || continue
|
||||
grep -q "^CONFIG_XEN=y\$" $cfg
|
||||
return
|
||||
|
@ -151,12 +150,12 @@ kernel_version_from_image() {
|
|||
local kernel_image="$1" kernel_image_gz="${dir}vmlinux-${1#*-}.gz"
|
||||
echo kernel_image_gz="'$kernel_image_gz'" >&2
|
||||
|
||||
if get_kernel_version "$kernel_image" 2>/dev/null; then
|
||||
if get_kernel_version "$kernel_image" 2> /dev/null; then
|
||||
return
|
||||
fi
|
||||
|
||||
# As a last resort, try vmlinux-$version.gz, which might be around
|
||||
get_kernel_version "$kernel_image_gz" 2>/dev/null
|
||||
get_kernel_version "$kernel_image_gz" 2> /dev/null
|
||||
}
|
||||
|
||||
# Taken over from SUSE mkinitrd
|
||||
|
@ -165,30 +164,31 @@ default_kernel_images() {
|
|||
local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
|
||||
|
||||
case "${DRACUT_ARCH:-$(uname -m)}" in
|
||||
s390|s390x)
|
||||
s390 | s390x)
|
||||
regex='image'
|
||||
;;
|
||||
ppc|ppc64)
|
||||
ppc | ppc64)
|
||||
regex='vmlinux'
|
||||
;;
|
||||
i?86|x86_64)
|
||||
i?86 | x86_64)
|
||||
regex='vmlinuz'
|
||||
;;
|
||||
arm*)
|
||||
regex='[uz]Image'
|
||||
;;
|
||||
aarch64|riscv64)
|
||||
aarch64 | riscv64)
|
||||
regex='Image'
|
||||
;;
|
||||
*) regex='vmlinu.'
|
||||
*)
|
||||
regex='vmlinu.'
|
||||
;;
|
||||
esac
|
||||
|
||||
kernel_images=""
|
||||
initrd_images=""
|
||||
for kernel_image in $(ls $boot_dir \
|
||||
| sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
|
||||
| grep -v kdump$ ) ; do
|
||||
| sed -ne "\|^$regex\(-[0-9.]\+-[0-9]\+-[a-z0-9]\+$\)\?|p" \
|
||||
| grep -v kdump$); do
|
||||
|
||||
# Note that we cannot check the RPM database here -- this
|
||||
# script is itself called from within the binary kernel
|
||||
|
@ -198,120 +198,137 @@ default_kernel_images() {
|
|||
[ "${kernel_image%%.gz}" != "$kernel_image" ] && continue
|
||||
|
||||
kernel_version=$(kernel_version_from_image \
|
||||
$boot_dir/$kernel_image 2> /dev/null)
|
||||
$boot_dir/$kernel_image 2> /dev/null)
|
||||
initrd_image=$(echo $kernel_image | sed -e "s|${regex}|initrd|")
|
||||
if [ "$kernel_image" != "$initrd_image" -a \
|
||||
-n "$kernel_version" -a \
|
||||
-d "/lib/modules/$kernel_version" ]; then
|
||||
kernel_images="$kernel_images $boot_dir/$kernel_image"
|
||||
initrd_images="$initrd_images $boot_dir/$initrd_image"
|
||||
-n "$kernel_version" -a \
|
||||
-d "/lib/modules/$kernel_version" ]; then
|
||||
kernel_images="$kernel_images $boot_dir/$kernel_image"
|
||||
initrd_images="$initrd_images $boot_dir/$initrd_image"
|
||||
fi
|
||||
done
|
||||
for kernel_image in $kernel_images;do
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
for kernel_image in $kernel_images; do
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
done
|
||||
for initrd_image in $initrd_images;do
|
||||
targets="$targets $initrd_image"
|
||||
for initrd_image in $initrd_images; do
|
||||
targets="$targets $initrd_image"
|
||||
done
|
||||
}
|
||||
|
||||
while (($# > 0)); do
|
||||
case ${1%%=*} in
|
||||
-f) read_arg feature_list "$@" || shift $?
|
||||
# Could be several features
|
||||
;;
|
||||
-k) # Would be nice to get a list of images here
|
||||
read_arg kernel_images "$@" || shift $?
|
||||
for kernel_image in $kernel_images;do
|
||||
[ -L "/boot/$kernel_image" ] && kernel_image="$(readlink "/boot/$kernel_image")"
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
done
|
||||
;;
|
||||
-i) read_arg initrd_images "$@" || shift $?
|
||||
for initrd_image in $initrd_images;do
|
||||
[ -L "/boot/$initrd_image" ] && initrd_image="$(readlink "/boot/$initrd_image")"
|
||||
# Check if the initrd_image contains a path.
|
||||
# if not, then add the default boot_dir
|
||||
dname=`dirname $initrd_image`
|
||||
if [ "$dname" == "." ]; then
|
||||
targets="$targets $boot_dir/$initrd_image";
|
||||
else
|
||||
targets="$targets $initrd_image";
|
||||
fi
|
||||
done
|
||||
;;
|
||||
-b) read_arg boot_dir "$@" || shift $?
|
||||
if [ ! -d $boot_dir ];then
|
||||
error "Boot directory $boot_dir does not exist"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-t) read_arg tmp_dir "$@" || shift $?
|
||||
dracut_args="${dracut_args} --tmpdir $tmp_dir"
|
||||
;;
|
||||
-M) read_arg map_file "$@" || shift $?
|
||||
;;
|
||||
-A) dracut_args="${dracut_args} --no-host-only";;
|
||||
-B) skip_update_bootloader=1;;
|
||||
-v|--verbose) dracut_args="${dracut_args} -v";;
|
||||
-L) logfile=;;
|
||||
-h|--help) usage -n;;
|
||||
-m) read_arg module_list "$@" || shift $? ;;
|
||||
-u) read_arg domu_module_list "$@" || shift $?
|
||||
echo "mkinitrd: DomU modules not yet supported" ;;
|
||||
-d) read_arg rootfs "$@" || shift $?
|
||||
dracut_args="${dracut_args} --filesystems $rootfs" ;;
|
||||
-D) read_arg dhcp_if "$@" || shift $?
|
||||
dracut_cmdline="${dracut_cmdline} ip=${dhcp_if}:dhcp"
|
||||
;;
|
||||
-I) read_arg static_if "$@" || shift $?
|
||||
dracut_cmdline="${dracut_cmdline} ip=$(ipconfig $static_if)":
|
||||
;;
|
||||
-a) read_arg acpi_dsdt "$@" || shift $?
|
||||
echo "Obsolete -a param, use acpi_table_dir= and acpi_override= variables in /etc/dracut.conf.d/"
|
||||
exit 1
|
||||
;;
|
||||
-s) read_arg boot_splash "$@" || shift $?
|
||||
echo "mkinitrd: boot splash not yet supported"
|
||||
exit 1
|
||||
;;
|
||||
-V) echo "mkinitrd: vendor scipts are no longer supported"
|
||||
exit 1;;
|
||||
--dracut)
|
||||
read_arg dracut_cmd "$@" || shift $? ;;
|
||||
--version|-R)
|
||||
-f)
|
||||
read_arg feature_list "$@" || shift $?
|
||||
# Could be several features
|
||||
;;
|
||||
-k) # Would be nice to get a list of images here
|
||||
read_arg kernel_images "$@" || shift $?
|
||||
for kernel_image in $kernel_images; do
|
||||
[ -L "/boot/$kernel_image" ] && kernel_image="$(readlink "/boot/$kernel_image")"
|
||||
kernels="$kernels ${kernel_image#*-}"
|
||||
done
|
||||
;;
|
||||
-i)
|
||||
read_arg initrd_images "$@" || shift $?
|
||||
for initrd_image in $initrd_images; do
|
||||
[ -L "/boot/$initrd_image" ] && initrd_image="$(readlink "/boot/$initrd_image")"
|
||||
# Check if the initrd_image contains a path.
|
||||
# if not, then add the default boot_dir
|
||||
dname=$(dirname $initrd_image)
|
||||
if [ "$dname" == "." ]; then
|
||||
targets="$targets $boot_dir/$initrd_image"
|
||||
else
|
||||
targets="$targets $initrd_image"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
-b)
|
||||
read_arg boot_dir "$@" || shift $?
|
||||
if [ ! -d $boot_dir ]; then
|
||||
error "Boot directory $boot_dir does not exist"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-t)
|
||||
read_arg tmp_dir "$@" || shift $?
|
||||
dracut_args="${dracut_args} --tmpdir $tmp_dir"
|
||||
;;
|
||||
-M)
|
||||
read_arg map_file "$@" || shift $?
|
||||
;;
|
||||
-A) dracut_args="${dracut_args} --no-host-only" ;;
|
||||
-B) skip_update_bootloader=1 ;;
|
||||
-v | --verbose) dracut_args="${dracut_args} -v" ;;
|
||||
-L) logfile= ;;
|
||||
-h | --help) usage -n ;;
|
||||
-m) read_arg module_list "$@" || shift $? ;;
|
||||
-u)
|
||||
read_arg domu_module_list "$@" || shift $?
|
||||
echo "mkinitrd: DomU modules not yet supported"
|
||||
;;
|
||||
-d)
|
||||
read_arg rootfs "$@" || shift $?
|
||||
dracut_args="${dracut_args} --filesystems $rootfs"
|
||||
;;
|
||||
-D)
|
||||
read_arg dhcp_if "$@" || shift $?
|
||||
dracut_cmdline="${dracut_cmdline} ip=${dhcp_if}:dhcp"
|
||||
;;
|
||||
-I)
|
||||
read_arg static_if "$@" || shift $?
|
||||
dracut_cmdline="${dracut_cmdline} ip=$(ipconfig $static_if)":
|
||||
;;
|
||||
-a)
|
||||
read_arg acpi_dsdt "$@" || shift $?
|
||||
echo "Obsolete -a param, use acpi_table_dir= and acpi_override= variables in /etc/dracut.conf.d/"
|
||||
exit 1
|
||||
;;
|
||||
-s)
|
||||
read_arg boot_splash "$@" || shift $?
|
||||
echo "mkinitrd: boot splash not yet supported"
|
||||
exit 1
|
||||
;;
|
||||
-V)
|
||||
echo "mkinitrd: vendor scipts are no longer supported"
|
||||
exit 1
|
||||
;;
|
||||
--dracut)
|
||||
read_arg dracut_cmd "$@" || shift $?
|
||||
;;
|
||||
--version | -R)
|
||||
echo "mkinitrd: dracut compatibility wrapper"
|
||||
exit 0;;
|
||||
--quiet|-q) quiet=1;;
|
||||
*) if [[ ! $targets ]]; then
|
||||
exit 0
|
||||
;;
|
||||
--quiet | -q) quiet=1 ;;
|
||||
*) if [[ ! $targets ]]; then
|
||||
targets=$1
|
||||
elif [[ ! $kernels ]]; then
|
||||
elif [[ ! $kernels ]]; then
|
||||
kernels=$1
|
||||
else
|
||||
else
|
||||
usage
|
||||
fi;;
|
||||
fi ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[[ $targets && $kernels ]] || default_kernel_images
|
||||
if [[ ! $targets || ! $kernels ]];then
|
||||
if [[ ! $targets || ! $kernels ]]; then
|
||||
error "No kernel found in $boot_dir or bad modules dir in /lib/modules"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We can have several targets/kernels, transform the list to an array
|
||||
targets=( $targets )
|
||||
[[ $kernels ]] && kernels=( $kernels )
|
||||
targets=($targets)
|
||||
[[ $kernels ]] && kernels=($kernels)
|
||||
|
||||
[[ $logfile ]] && dracut_args="${dracut_args} --logfile $logfile"
|
||||
[[ $logfile ]] && dracut_args="${dracut_args} --logfile $logfile"
|
||||
dracut_args="${dracut_args} --force"
|
||||
|
||||
[[ $dracut_cmdline ]] && dracut_args="${dracut_args} --kernel-cmdline ${dracut_cmdline}"
|
||||
[ -z "$(type -p update-bootloader)" ] && skip_update_bootloader=1
|
||||
|
||||
# Update defaults from /etc/sysconfig/kernel
|
||||
if [ -f /etc/sysconfig/kernel ] ; then
|
||||
if [ -f /etc/sysconfig/kernel ]; then
|
||||
. /etc/sysconfig/kernel
|
||||
fi
|
||||
[[ $module_list ]] || module_list="${INITRD_MODULES}"
|
||||
|
@ -320,17 +337,17 @@ shopt -s extglob
|
|||
|
||||
failed=""
|
||||
|
||||
for ((i=0 ; $i<${#targets[@]} ; i++)); do
|
||||
for ((i = 0; $i < ${#targets[@]}; i++)); do
|
||||
|
||||
if [[ $img_vers ]];then
|
||||
target="${targets[$i]}-${kernels[$i]}"
|
||||
if [[ $img_vers ]]; then
|
||||
target="${targets[$i]}-${kernels[$i]}"
|
||||
else
|
||||
target="${targets[$i]}"
|
||||
target="${targets[$i]}"
|
||||
fi
|
||||
kernel="${kernels[$i]}"
|
||||
|
||||
if is_xen_kernel $kernel $rootfs ; then
|
||||
modules_all="${module_list} ${domu_module_list}"
|
||||
if is_xen_kernel $kernel $rootfs; then
|
||||
modules_all="${module_list} ${domu_module_list}"
|
||||
else
|
||||
modules_all="${module_list}"
|
||||
fi
|
||||
|
@ -342,19 +359,19 @@ for ((i=0 ; $i<${#targets[@]} ; i++)); do
|
|||
echo "Creating initrd: $target"
|
||||
|
||||
# Duplicate code: No way found how to redirect output based on $quiet
|
||||
if [[ $quiet == 1 ]];then
|
||||
if [[ $quiet == 1 ]]; then
|
||||
# Duplicate code: --force-drivers must not be called with empty string
|
||||
# -> dracut bug workarounded ugly, because of complex whitespace
|
||||
# expansion magics
|
||||
if [ -n "${modules_all}" ];then
|
||||
$dracut_cmd $dracut_args --force-drivers "${modules_all}" "$target" "$kernel" &>/dev/null
|
||||
if [ -n "${modules_all}" ]; then
|
||||
$dracut_cmd $dracut_args --force-drivers "${modules_all}" "$target" "$kernel" &> /dev/null
|
||||
[ $? -ne 0 ] && failed="$failed $target"
|
||||
else
|
||||
$dracut_cmd $dracut_args "$target" "$kernel" &>/dev/null
|
||||
$dracut_cmd $dracut_args "$target" "$kernel" &> /dev/null
|
||||
[ $? -ne 0 ] && failed="$failed $target"
|
||||
fi
|
||||
else
|
||||
if [ -n "${modules_all}" ];then
|
||||
if [ -n "${modules_all}" ]; then
|
||||
$dracut_cmd $dracut_args --force-drivers "${modules_all}" "$target" "$kernel"
|
||||
[ $? -ne 0 ] && failed="$failed $target"
|
||||
else
|
||||
|
@ -364,7 +381,7 @@ for ((i=0 ; $i<${#targets[@]} ; i++)); do
|
|||
fi
|
||||
done
|
||||
|
||||
if [ "$skip_update_bootloader" ] ; then
|
||||
if [ "$skip_update_bootloader" ]; then
|
||||
echo 2>&1 "Did not refresh the bootloader. You might need to refresh it manually."
|
||||
else
|
||||
update-bootloader --refresh
|
||||
|
|
|
@ -18,4 +18,3 @@ install() {
|
|||
# Prefer bash as /bin/sh if it is available.
|
||||
inst /bin/bash && ln -sf bash "${initdir}/bin/sh"
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,3 @@ install() {
|
|||
# Prefer dash as /bin/sh if it is available.
|
||||
inst /bin/dash && ln -sf dash "${initdir}/bin/sh"
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,3 @@ install() {
|
|||
# Prefer mksh as /bin/sh if it is available.
|
||||
inst /bin/mksh && ln -sf mksh "${initdir}/bin/sh"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
getSystemdVersion() {
|
||||
[ -z "$SYSTEMD_VERSION" ] && SYSTEMD_VERSION=$("$systemdutildir"/systemd --version | { read -r _ b _; echo "$b"; })
|
||||
[ -z "$SYSTEMD_VERSION" ] && SYSTEMD_VERSION=$("$systemdutildir"/systemd --version | {
|
||||
read -r _ b _
|
||||
echo "$b"
|
||||
})
|
||||
# Check if the systemd version is a valid number
|
||||
if ! [[ $SYSTEMD_VERSION =~ ^[0-9]+$ ]]; then
|
||||
dfatal "systemd version is not a number ($SYSTEMD_VERSION)"
|
||||
|
@ -16,8 +19,8 @@ check() {
|
|||
[[ $mount_needs ]] && return 1
|
||||
if require_binaries "$systemdutildir"/systemd; then
|
||||
SYSTEMD_VERSION=$(getSystemdVersion)
|
||||
(( SYSTEMD_VERSION >= 198 )) && return 0
|
||||
return 255
|
||||
((SYSTEMD_VERSION >= 198)) && return 0
|
||||
return 255
|
||||
fi
|
||||
|
||||
return 1
|
||||
|
@ -43,9 +46,9 @@ install() {
|
|||
fi
|
||||
|
||||
if [[ $(getSystemdVersion) -ge 240 ]]; then
|
||||
inst_multiple -o \
|
||||
"$systemdutildir"/system-generators/systemd-debug-generator \
|
||||
"$systemdsystemunitdir"/debug-shell.service
|
||||
inst_multiple -o \
|
||||
"$systemdutildir"/system-generators/systemd-debug-generator \
|
||||
"$systemdsystemunitdir"/debug-shell.service
|
||||
fi
|
||||
|
||||
inst_multiple -o \
|
||||
|
@ -170,12 +173,13 @@ install() {
|
|||
[[ -f $i ]] || continue
|
||||
while read -r _line || [ -n "$_line" ]; do
|
||||
case $_line in
|
||||
\#*)
|
||||
;;
|
||||
\;*)
|
||||
;;
|
||||
\#*) ;;
|
||||
|
||||
\;*) ;;
|
||||
|
||||
*)
|
||||
echo "$_line"
|
||||
;;
|
||||
esac
|
||||
done < "$i"
|
||||
done
|
||||
|
@ -211,8 +215,8 @@ install() {
|
|||
|
||||
# install adm user/group for journald
|
||||
inst_multiple nologin
|
||||
grep '^systemd-journal:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
|
||||
grep '^adm:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
|
||||
grep '^systemd-journal:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
|
||||
grep '^adm:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
|
||||
grep '^systemd-journal:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
|
||||
grep '^wheel:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
|
||||
grep '^adm:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
|
||||
|
@ -220,7 +224,7 @@ install() {
|
|||
grep '^root:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
|
||||
|
||||
# we don't use systemd-networkd, but the user is in systemd.conf tmpfiles snippet
|
||||
grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
|
||||
grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
|
||||
grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
|
||||
|
||||
ln_r "$systemdutildir"/systemd "/init"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
if test -e /etc/adjtime ; then
|
||||
while read line ; do
|
||||
if test "$line" = LOCAL ; then
|
||||
hwclock --systz
|
||||
fi
|
||||
if test -e /etc/adjtime; then
|
||||
while read line; do
|
||||
if test "$line" = LOCAL; then
|
||||
hwclock --systz
|
||||
fi
|
||||
done < /etc/adjtime
|
||||
fi
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
if ! fipsmode=$(getarg fips) || [ "$fipsmode" = "0" ]; then
|
||||
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
rm -f -- /etc/modprobe.d/fips.conf > /dev/null 2>&1
|
||||
elif [ -z "$fipsmode" ]; then
|
||||
die "FIPS mode have to be enabled by 'fips=1' not just 'fips'"
|
||||
elif getarg boot= >/dev/null; then
|
||||
elif getarg boot= > /dev/null; then
|
||||
. /sbin/fips.sh
|
||||
if mount_boot; then
|
||||
do_fips || die "FIPS integrity test failed"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
|
||||
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
rm -f -- /etc/modprobe.d/fips.conf > /dev/null 2>&1
|
||||
else
|
||||
. /sbin/fips.sh
|
||||
fips_load_crypto || die "FIPS integrity test failed"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
if ! fipsmode=$(getarg fips) || [ "$fipsmode" = "0" ]; then
|
||||
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
rm -f -- /etc/modprobe.d/fips.conf > /dev/null 2>&1
|
||||
elif [ -z "$fipsmode" ]; then
|
||||
die "FIPS mode have to be enabled by 'fips=1' not just 'fips'"
|
||||
elif ! [ -f /tmp/fipsdone ]; then
|
||||
|
|
|
@ -12,23 +12,23 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
mount_boot()
|
||||
{
|
||||
mount_boot() {
|
||||
boot=$(getarg boot=)
|
||||
|
||||
if [ -n "$boot" ]; then
|
||||
case "$boot" in
|
||||
LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
|
||||
boot="$(label_uuid_to_dev "$boot")"
|
||||
;;
|
||||
/dev/*)
|
||||
;;
|
||||
*)
|
||||
die "You have to specify boot=<boot device> as a boot option for fips=1" ;;
|
||||
LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
|
||||
boot="$(label_uuid_to_dev "$boot")"
|
||||
;;
|
||||
/dev/*) ;;
|
||||
|
||||
*)
|
||||
die "You have to specify boot=<boot device> as a boot option for fips=1"
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! [ -e "$boot" ]; then
|
||||
udevadm trigger --action=add >/dev/null 2>&1
|
||||
udevadm trigger --action=add > /dev/null 2>&1
|
||||
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
|
||||
i=0
|
||||
while ! [ -e $boot ]; do
|
||||
|
@ -39,7 +39,7 @@ mount_boot()
|
|||
fi
|
||||
[ -e $boot ] && break
|
||||
sleep 0.5
|
||||
i=$(($i+1))
|
||||
i=$(($i + 1))
|
||||
[ $i -gt 40 ] && break
|
||||
done
|
||||
fi
|
||||
|
@ -55,8 +55,7 @@ mount_boot()
|
|||
fi
|
||||
}
|
||||
|
||||
do_rhevh_check()
|
||||
{
|
||||
do_rhevh_check() {
|
||||
KERNEL=$(uname -r)
|
||||
kpath=${1}
|
||||
|
||||
|
@ -71,23 +70,21 @@ do_rhevh_check()
|
|||
return 0
|
||||
}
|
||||
|
||||
nonfatal_modprobe()
|
||||
{
|
||||
modprobe $1 2>&1 > /dev/stdout |
|
||||
while read -r line || [ -n "$line" ]; do
|
||||
nonfatal_modprobe() {
|
||||
modprobe $1 2>&1 > /dev/stdout \
|
||||
| while read -r line || [ -n "$line" ]; do
|
||||
echo "${line#modprobe: FATAL: }" >&2
|
||||
done
|
||||
}
|
||||
|
||||
fips_load_crypto()
|
||||
{
|
||||
fips_load_crypto() {
|
||||
FIPSMODULES=$(cat /etc/fipsmodules)
|
||||
|
||||
fips_info "Loading and integrity checking all crypto modules"
|
||||
mv /etc/modprobe.d/fips.conf /etc/modprobe.d/fips.conf.bak
|
||||
for _module in $FIPSMODULES; do
|
||||
if [ "$_module" != "tcrypt" ]; then
|
||||
if ! nonfatal_modprobe "${_module}" 2>/tmp/fips.modprobe_err; then
|
||||
if ! nonfatal_modprobe "${_module}" 2> /tmp/fips.modprobe_err; then
|
||||
# check if kernel provides generic algo
|
||||
_found=0
|
||||
while read _k _s _v || [ -n "$_k" ]; do
|
||||
|
@ -95,7 +92,7 @@ fips_load_crypto()
|
|||
[ "$_v" != "$_module" ] && continue
|
||||
_found=1
|
||||
break
|
||||
done </proc/crypto
|
||||
done < /proc/crypto
|
||||
[ "$_found" = "0" ] && cat /tmp/fips.modprobe_err >&2 && return 1
|
||||
fi
|
||||
fi
|
||||
|
@ -107,8 +104,7 @@ fips_load_crypto()
|
|||
rmmod tcrypt
|
||||
}
|
||||
|
||||
do_fips()
|
||||
{
|
||||
do_fips() {
|
||||
local _v
|
||||
local _s
|
||||
local _v
|
||||
|
@ -159,7 +155,7 @@ do_fips()
|
|||
|
||||
> /tmp/fipsdone
|
||||
|
||||
umount /boot >/dev/null 2>&1
|
||||
umount /boot > /dev/null 2>&1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -34,26 +34,26 @@ install() {
|
|||
$systemdsystemunitdir/sysinit.target.wants/systemd-ask-password-console.path \
|
||||
systemd-ask-password systemd-tty-ask-password-agent
|
||||
|
||||
# Enable the systemd type service unit for systemd-ask-password.
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-console.service
|
||||
# Enable the systemd type service unit for systemd-ask-password.
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-console.service
|
||||
|
||||
# Install systemd-ask-password plymouth units if plymouth is enabled.
|
||||
if dracut_module_included "plymouth"; then
|
||||
inst_multiple -o \
|
||||
$systemdsystemunitdir/systemd-ask-password-plymouth.path \
|
||||
$systemdsystemunitdir/systemd-ask-password-plymouth.service
|
||||
# Install systemd-ask-password plymouth units if plymouth is enabled.
|
||||
if dracut_module_included "plymouth"; then
|
||||
inst_multiple -o \
|
||||
$systemdsystemunitdir/systemd-ask-password-plymouth.path \
|
||||
$systemdsystemunitdir/systemd-ask-password-plymouth.service
|
||||
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-plymouth.service
|
||||
fi
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-plymouth.service
|
||||
fi
|
||||
|
||||
# Uncomment this section if the usecase for wall module in the initramfs arises.
|
||||
# Install systemd-ask-password wall units if <wall module> is enabled.
|
||||
#if dracut_module_included "<wall module>"; then
|
||||
# inst_multiple -o \
|
||||
# $systemdsystemunitdir/systemd-ask-password-wall.path \
|
||||
# $systemdsystemunitdir/systemd-ask-password-wall.service \
|
||||
# $systemdsystemunitdir/multi-user.target.wants/systemd-ask-password-wall.path
|
||||
#
|
||||
# $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-wall.service
|
||||
#fi
|
||||
# Uncomment this section if the usecase for wall module in the initramfs arises.
|
||||
# Install systemd-ask-password wall units if <wall module> is enabled.
|
||||
#if dracut_module_included "<wall module>"; then
|
||||
# inst_multiple -o \
|
||||
# $systemdsystemunitdir/systemd-ask-password-wall.path \
|
||||
# $systemdsystemunitdir/systemd-ask-password-wall.service \
|
||||
# $systemdsystemunitdir/multi-user.target.wants/systemd-ask-password-wall.path
|
||||
#
|
||||
# $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-wall.service
|
||||
#fi
|
||||
}
|
||||
|
|
|
@ -27,14 +27,13 @@ depends() {
|
|||
# Install the required file(s) and directories for the module in the initramfs.
|
||||
install() {
|
||||
|
||||
inst_dir /var/lib/systemd/coredump
|
||||
inst_dir /var/lib/systemd/coredump
|
||||
inst_multiple -o \
|
||||
$sysctld/50-coredump.conf \
|
||||
$systemdutildir/coredump.conf \
|
||||
$systemdsystemunitdir/systemd-coredump \
|
||||
$systemdsystemunitdir/systemd-coredump.socket \
|
||||
$systemdsystemunitdir/systemd-coredump@.service\
|
||||
$systemdsystemunitdir/sockets.target.wants/systemd-coredump.socket \
|
||||
$systemdsystemunitdir/systemd-coredump@.service $systemdsystemunitdir/sockets.target.wants/systemd-coredump.socket \
|
||||
coredumpctl
|
||||
|
||||
# Install the hosts local user configurations if enabled.
|
||||
|
|
|
@ -26,24 +26,24 @@ depends() {
|
|||
# Install the required file(s) for the module in the initramfs.
|
||||
install() {
|
||||
|
||||
# Create systemd-modules-load related directories.
|
||||
inst_dir $modulesload
|
||||
inst_dir $modulesloadconfdir
|
||||
# Create systemd-modules-load related directories.
|
||||
inst_dir $modulesload
|
||||
inst_dir $modulesloadconfdir
|
||||
|
||||
# Install related files for systemd-modules-load
|
||||
inst_multiple -o \
|
||||
$systemdsystemunitdir/systemd-modules-load.service \
|
||||
$systemdutildir/systemd-modules-load
|
||||
# Install related files for systemd-modules-load
|
||||
inst_multiple -o \
|
||||
$systemdsystemunitdir/systemd-modules-load.service \
|
||||
$systemdutildir/systemd-modules-load
|
||||
|
||||
# Install local user configurations if host only is enabled..
|
||||
if [[ $hostonly ]]; then
|
||||
inst_multiple -H -o \
|
||||
# Install local user configurations if host only is enabled..
|
||||
if [[ $hostonly ]]; then
|
||||
inst_multiple -H -o \
|
||||
$systemdsystemconfdir/systemd-modules-load.service \
|
||||
$systemdsystemconfdir/systemd-systemd-modules-load.d/*.conf \
|
||||
${NULL}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable the systemd type service unit for systemd-modules-load.
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-modules-load.service
|
||||
# Enable the systemd type service unit for systemd-modules-load.
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-modules-load.service
|
||||
|
||||
}
|
||||
|
|
|
@ -37,17 +37,17 @@ install() {
|
|||
$systemdsystemunitdir/systemd-sysusers.service \
|
||||
systemd-sysusers
|
||||
|
||||
# Install the hosts local user configurations if enabled.
|
||||
if [[ $hostonly ]]; then
|
||||
inst_multiple -H -o \
|
||||
# Install the hosts local user configurations if enabled.
|
||||
if [[ $hostonly ]]; then
|
||||
inst_multiple -H -o \
|
||||
$sysusersconfdir/basic.conf \
|
||||
$sysusersconfdir/systemd.conf \
|
||||
$systemdsystemconfdir/systemd-sysusers.service \
|
||||
$systemdsystemconfdir/systemd-sysusers.service.d/*.conf \
|
||||
${NULL}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable the systemd type service unit for sysusers.
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-sysusers.service
|
||||
# Enable the systemd type service unit for sysusers.
|
||||
$SYSTEMCTL -q --root "$initdir" enable systemd-sysusers.service
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ if [ "$capsmode" = "1" ]; then
|
|||
CAPS_KEXEC_DISABLED=$(getarg rd.caps.disablekexec=)
|
||||
|
||||
info "Loading CAPS_MODULES $CAPS_MODULES"
|
||||
for i in $CAPS_MODULES;do modprobe "$i" 2>&1 >/dev/null | vinfo; done
|
||||
for i in $CAPS_MODULES; do modprobe "$i" 2>&1 > /dev/null | vinfo; done
|
||||
|
||||
if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then
|
||||
info "Disabling module loading."
|
||||
|
@ -32,4 +32,3 @@ if [ "$capsmode" = "1" ]; then
|
|||
echo "CAPS_INIT_DROP=\"$CAPS_INIT_DROP\"" > /etc/capsdrop
|
||||
info "Will drop capabilities $CAPS_INIT_DROP from init."
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,11 +15,10 @@ depends() {
|
|||
install() {
|
||||
if ! dracut_module_included "systemd"; then
|
||||
inst_hook pre-pivot 00 "$moddir/caps.sh"
|
||||
inst $(find_binary capsh 2>/dev/null) /usr/sbin/capsh
|
||||
inst $(find_binary capsh 2> /dev/null) /usr/sbin/capsh
|
||||
# capsh wants bash and we need bash also
|
||||
inst /bin/bash
|
||||
else
|
||||
dwarning "caps: does not work with systemd in the initramfs"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -27,33 +27,32 @@ install() {
|
|||
$systemdutildir/network/99-default.link \
|
||||
networkctl ip
|
||||
|
||||
#hostnamectl timedatectl
|
||||
# $systemdutildir/systemd-timesyncd \
|
||||
# $systemdutildir/systemd-timedated \
|
||||
# $systemdutildir/systemd-hostnamed \
|
||||
# $systemdutildir/systemd-resolvd \
|
||||
# $systemdutildir/systemd-resolve-host \
|
||||
# $systemdsystemunitdir/systemd-resolved.service \
|
||||
# $systemdsystemunitdir/systemd-hostnamed.service \
|
||||
# $systemdsystemunitdir/systemd-timesyncd.service \
|
||||
# $systemdsystemunitdir/systemd-timedated.service \
|
||||
# $systemdsystemunitdir/time-sync.target \
|
||||
# /etc/systemd/resolved.conf \
|
||||
|
||||
#hostnamectl timedatectl
|
||||
# $systemdutildir/systemd-timesyncd \
|
||||
# $systemdutildir/systemd-timedated \
|
||||
# $systemdutildir/systemd-hostnamed \
|
||||
# $systemdutildir/systemd-resolvd \
|
||||
# $systemdutildir/systemd-resolve-host \
|
||||
# $systemdsystemunitdir/systemd-resolved.service \
|
||||
# $systemdsystemunitdir/systemd-hostnamed.service \
|
||||
# $systemdsystemunitdir/systemd-timesyncd.service \
|
||||
# $systemdsystemunitdir/systemd-timedated.service \
|
||||
# $systemdsystemunitdir/time-sync.target \
|
||||
# /etc/systemd/resolved.conf \
|
||||
|
||||
# inst_dir /var/lib/systemd/clock
|
||||
|
||||
grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
|
||||
grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
|
||||
grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
|
||||
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
|
||||
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
|
||||
|
||||
_arch=${DRACUT_ARCH:-$(uname -m)}
|
||||
inst_libdir_file \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_resolve.so.*"
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_resolve.so.*"
|
||||
|
||||
# systemd-timesyncd.service
|
||||
for i in \
|
||||
|
@ -64,4 +63,3 @@ install() {
|
|||
$SYSTEMCTL -q --root "$initdir" enable "$i"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# Copyright 2013 Red Hat, Inc.
|
||||
# Peter Jones <pjones@redhat.com>
|
||||
|
||||
for x in /lib/modules/keys/* ; do
|
||||
for x in /lib/modules/keys/*; do
|
||||
[ "${x}" = "/lib/modules/keys/*" ] && break
|
||||
keyctl padd asymmetric "" @s < ${x}
|
||||
done
|
||||
|
|
|
@ -31,7 +31,7 @@ install() {
|
|||
|
||||
inst_hook pre-trigger 01 "$moddir/load-modsign-keys.sh"
|
||||
|
||||
for x in "$dracutsysrootdir"/lib/modules/keys/* ; do
|
||||
for x in "$dracutsysrootdir"/lib/modules/keys/*; do
|
||||
[[ "${x}" = "$dracutsysrootdir/lib/modules/keys/*" ]] && break
|
||||
inst_simple "${x#$dracutsysrootdir}"
|
||||
done
|
||||
|
|
|
@ -17,4 +17,3 @@ install() {
|
|||
ping netstat rpcinfo vi scp ping6 ssh \
|
||||
fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.f2fs fsck.vfat e2fsck
|
||||
}
|
||||
|
||||
|
|
|
@ -16,17 +16,17 @@ install() {
|
|||
# Do not add watchdog hooks if systemd module is included
|
||||
# In that case, systemd will manage watchdog kick
|
||||
if ! dracut_module_included "systemd"; then
|
||||
inst_hook cmdline 00 "$moddir/watchdog.sh"
|
||||
inst_hook cmdline 50 "$moddir/watchdog.sh"
|
||||
inst_hook cmdline 00 "$moddir/watchdog.sh"
|
||||
inst_hook cmdline 50 "$moddir/watchdog.sh"
|
||||
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
|
||||
inst_hook initqueue 00 "$moddir/watchdog.sh"
|
||||
inst_hook mount 00 "$moddir/watchdog.sh"
|
||||
inst_hook mount 50 "$moddir/watchdog.sh"
|
||||
inst_hook mount 99 "$moddir/watchdog.sh"
|
||||
inst_hook mount 00 "$moddir/watchdog.sh"
|
||||
inst_hook mount 50 "$moddir/watchdog.sh"
|
||||
inst_hook mount 99 "$moddir/watchdog.sh"
|
||||
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
|
||||
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 00 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 99 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 00 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 99 "$moddir/watchdog.sh"
|
||||
fi
|
||||
|
||||
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/bin/sh
|
||||
if [ -e /dev/watchdog ]; then
|
||||
if [ ! -e /tmp/watchdog_timeout ]; then
|
||||
wdctl -s 60 /dev/watchdog >/dev/null 2>&1
|
||||
> /tmp/watchdog_timeout
|
||||
fi
|
||||
info "Triggering watchdog"
|
||||
>/dev/watchdog
|
||||
if [ ! -e /tmp/watchdog_timeout ]; then
|
||||
wdctl -s 60 /dev/watchdog > /dev/null 2>&1
|
||||
> /tmp/watchdog_timeout
|
||||
fi
|
||||
info "Triggering watchdog"
|
||||
> /dev/watchdog
|
||||
else
|
||||
modprobe ib700wdt
|
||||
modprobe i6300esb
|
||||
modprobe ib700wdt
|
||||
modprobe i6300esb
|
||||
fi
|
||||
|
|
|
@ -29,4 +29,3 @@ install() {
|
|||
ln_r /usr/bin/busybox $_path
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ install() {
|
|||
/^\[Socket\]/aRemoveOnStop=yes' \
|
||||
"$initdir$systemdsystemunitdir/dbus.socket"
|
||||
|
||||
|
||||
# Install the hosts local user configurations if enabled.
|
||||
if [[ $hostonly ]]; then
|
||||
inst_multiple -H -o \
|
||||
|
|
|
@ -65,7 +65,7 @@ install() {
|
|||
|
||||
# Adjusting dependencies for initramfs in the dbus socket unit.
|
||||
sed -i -e \
|
||||
'/^\[Unit\]/aDefaultDependencies=no\
|
||||
'/^\[Unit\]/aDefaultDependencies=no\
|
||||
Conflicts=shutdown.target\
|
||||
Before=shutdown.target
|
||||
/^\[Socket\]/aRemoveOnStop=yes' \
|
||||
|
@ -84,7 +84,7 @@ install() {
|
|||
$systemdsystemconfdir/dbus.service \
|
||||
$systemdsystemconfdir/dbus.service.d/*.conf \
|
||||
${NULL}
|
||||
fi
|
||||
fi
|
||||
|
||||
# We need to make sure that systemd-tmpfiles-setup.service->dbus.socket
|
||||
# will not wait for local-fs.target to start if swap is encrypted,
|
||||
|
|
|
@ -13,13 +13,13 @@ depends() {
|
|||
local _module
|
||||
# Add a dbus meta dependency based on the module in use.
|
||||
for _module in dbus-daemon dbus-broker; do
|
||||
if dracut_module_included "$_module" ; then
|
||||
if dracut_module_included "$_module"; then
|
||||
echo "$_module"
|
||||
return 0
|
||||
fi
|
||||
done;
|
||||
done
|
||||
|
||||
if find_binary dbus-broker &> /dev/null ; then
|
||||
if find_binary dbus-broker &> /dev/null; then
|
||||
echo "dbus-broker"
|
||||
return 0
|
||||
else
|
||||
|
|
|
@ -45,7 +45,9 @@ set_keymap() {
|
|||
}
|
||||
|
||||
set_font() {
|
||||
local dev=$1; local trans=''; local uni=''
|
||||
local dev=$1
|
||||
local trans=''
|
||||
local uni=''
|
||||
|
||||
[ -z "${FONT}" ] && FONT=${DEFAULT_FONT}
|
||||
[ -n "${FONT_MAP}" ] && trans="-m ${FONT_MAP}"
|
||||
|
@ -62,8 +64,8 @@ dev_close() {
|
|||
dev_open() {
|
||||
local dev=$1
|
||||
|
||||
exec 6<${dev} && \
|
||||
exec 7>>${dev}
|
||||
exec 6< ${dev} \
|
||||
&& exec 7>> ${dev}
|
||||
}
|
||||
|
||||
dev=/dev/${1#/dev/}
|
||||
|
@ -90,4 +92,3 @@ set_font ${dev}
|
|||
set_keymap
|
||||
|
||||
dev_close
|
||||
|
||||
|
|
|
@ -28,19 +28,19 @@ install() {
|
|||
VCONFIG_CONF="/etc/vconsole.conf"
|
||||
|
||||
# This is from 10redhat-i18n.
|
||||
findkeymap () {
|
||||
findkeymap() {
|
||||
local MAPS=$1
|
||||
local MAPNAME=${1%.map*}
|
||||
local map
|
||||
[[ ! -f $dracutsysrootdir$MAPS ]] && \
|
||||
MAPS=$(find $dracutsysrootdir${kbddir}/keymaps -type f -name ${MAPNAME} -o -name ${MAPNAME}.map -o -name ${MAPNAME}.map.\*)
|
||||
[[ ! -f $dracutsysrootdir$MAPS ]] \
|
||||
&& MAPS=$(find $dracutsysrootdir${kbddir}/keymaps -type f -name ${MAPNAME} -o -name ${MAPNAME}.map -o -name ${MAPNAME}.map.\*)
|
||||
|
||||
for map in $MAPS; do
|
||||
KEYMAPS="$KEYMAPS $map "
|
||||
case $map in
|
||||
*.gz) cmd="zgrep";;
|
||||
*.bz2) cmd="bzgrep";;
|
||||
*) cmd="grep";;
|
||||
*.gz) cmd="zgrep" ;;
|
||||
*.bz2) cmd="bzgrep" ;;
|
||||
*) cmd="grep" ;;
|
||||
esac
|
||||
|
||||
for INCL in $($cmd "^include " $map | while read _ a _ || [ -n "$a" ]; do echo ${a//\"/}; done); do
|
||||
|
@ -52,43 +52,41 @@ install() {
|
|||
done
|
||||
}
|
||||
|
||||
# Function gathers variables from distributed files among the tree, maps to
|
||||
# specified names and prints the result in format "new-name=value".
|
||||
#
|
||||
# $@ = list in format specified below (BNF notation)
|
||||
#
|
||||
# <list> ::= <element> | <element> " " <list>
|
||||
# <element> ::= <conf-file-name> ":" <map-list>
|
||||
# <map-list> ::= <mapping> | <mapping> "," <map-list>
|
||||
# <mapping> ::= <src-var> "-" <dst-var> | <src-var>
|
||||
#
|
||||
# We assume no whitespace are allowed between symbols.
|
||||
# <conf-file-name> is a file holding <src-var> in your system.
|
||||
# <src-var> is a variable holding value of meaning the same as <dst-var>.
|
||||
# <dst-var> is a variable which will be set up inside initramfs.
|
||||
# If <dst-var> has the same name as <src-var> we can omit <dst-var>.
|
||||
#
|
||||
# Example:
|
||||
# /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <list> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <element> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <conf-file-name> = /etc/conf.d/keymaps
|
||||
# <map-list> = KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <mapping> = KEYMAP
|
||||
# <src-var> = KEYMAP
|
||||
# <mapping> = extended_keymaps-EXT_KEYMAPS
|
||||
# <src-var> = extended_keymaps
|
||||
# <dst-var> = EXT_KEYMAPS
|
||||
# Function gathers variables from distributed files among the tree, maps to
|
||||
# specified names and prints the result in format "new-name=value".
|
||||
#
|
||||
# $@ = list in format specified below (BNF notation)
|
||||
#
|
||||
# <list> ::= <element> | <element> " " <list>
|
||||
# <element> ::= <conf-file-name> ":" <map-list>
|
||||
# <map-list> ::= <mapping> | <mapping> "," <map-list>
|
||||
# <mapping> ::= <src-var> "-" <dst-var> | <src-var>
|
||||
#
|
||||
# We assume no whitespace are allowed between symbols.
|
||||
# <conf-file-name> is a file holding <src-var> in your system.
|
||||
# <src-var> is a variable holding value of meaning the same as <dst-var>.
|
||||
# <dst-var> is a variable which will be set up inside initramfs.
|
||||
# If <dst-var> has the same name as <src-var> we can omit <dst-var>.
|
||||
#
|
||||
# Example:
|
||||
# /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <list> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <element> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <conf-file-name> = /etc/conf.d/keymaps
|
||||
# <map-list> = KEYMAP,extended_keymaps-EXT_KEYMAPS
|
||||
# <mapping> = KEYMAP
|
||||
# <src-var> = KEYMAP
|
||||
# <mapping> = extended_keymaps-EXT_KEYMAPS
|
||||
# <src-var> = extended_keymaps
|
||||
# <dst-var> = EXT_KEYMAPS
|
||||
gather_vars() {
|
||||
local item map value
|
||||
|
||||
# FIXME: double check
|
||||
# shellcheck disable=SC2068
|
||||
for item in $@
|
||||
do
|
||||
for item in $@; do
|
||||
item=(${item/:/ })
|
||||
for map in ${item[1]//,/ }
|
||||
do
|
||||
for map in ${item[1]//,/ }; do
|
||||
map=(${map//-/ })
|
||||
if [[ -f "$dracutsysrootdir${item[0]}" ]]; then
|
||||
value=$(grep "^${map[0]}=" "$dracutsysrootdir${item[0]}")
|
||||
|
@ -129,12 +127,12 @@ install() {
|
|||
find "${initdir}${kbddir}/" -name README\* -delete
|
||||
find "${initdir}${kbddir}/" -name '*.gz' -print -quit \
|
||||
| while read line || [ -n "$line" ]; do
|
||||
inst_multiple gzip
|
||||
inst_multiple gzip
|
||||
done
|
||||
|
||||
find "${initdir}${kbddir}/" -name '*.bz2' -print -quit \
|
||||
| while read line || [ -n "$line" ]; do
|
||||
inst_multiple bzip2
|
||||
inst_multiple bzip2
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -146,20 +144,16 @@ install() {
|
|||
[ -f $dracutsysrootdir$VCONFIG_CONF ] && . $dracutsysrootdir$VCONFIG_CONF
|
||||
|
||||
shopt -q -s nocasematch
|
||||
if [[ ${UNICODE} ]]
|
||||
then
|
||||
if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]
|
||||
then
|
||||
if [[ ${UNICODE} ]]; then
|
||||
if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]; then
|
||||
UNICODE=1
|
||||
elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]
|
||||
then
|
||||
elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]; then
|
||||
UNICODE=0
|
||||
else
|
||||
UNICODE=''
|
||||
fi
|
||||
fi
|
||||
if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]
|
||||
then
|
||||
if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]; then
|
||||
UNICODE=1
|
||||
fi
|
||||
shopt -q -u nocasematch
|
||||
|
@ -174,10 +168,10 @@ install() {
|
|||
# determines whether non-UNICODE or UNICODE version is used
|
||||
|
||||
if [[ ${KEYTABLE} ]]; then
|
||||
if [[ ${UNICODE} == 1 ]]; then
|
||||
[[ ${KEYTABLE} =~ .*\.uni.* ]] || KEYTABLE=${KEYTABLE%.map*}.uni
|
||||
fi
|
||||
KEYMAP=${KEYTABLE}
|
||||
if [[ ${UNICODE} == 1 ]]; then
|
||||
[[ ${KEYTABLE} =~ .*\.uni.* ]] || KEYTABLE=${KEYTABLE%.map*}.uni
|
||||
fi
|
||||
KEYMAP=${KEYTABLE}
|
||||
fi
|
||||
|
||||
# I'm not sure of the purpose of UNIKEYMAP and GRP_TOGGLE. They were in
|
||||
|
@ -191,8 +185,7 @@ install() {
|
|||
|
||||
findkeymap ${KEYMAP}
|
||||
|
||||
for map in ${EXT_KEYMAPS}
|
||||
do
|
||||
for map in ${EXT_KEYMAPS}; do
|
||||
ddebug "Adding extra map: ${map}"
|
||||
findkeymap ${map}
|
||||
done
|
||||
|
@ -203,24 +196,21 @@ install() {
|
|||
|
||||
inst_opt_decompress ${kbddir}/consolefonts/${DEFAULT_FONT}.*
|
||||
|
||||
if [[ ${FONT} ]] && [[ ${FONT} != ${DEFAULT_FONT} ]]
|
||||
then
|
||||
if [[ ${FONT} ]] && [[ ${FONT} != ${DEFAULT_FONT} ]]; then
|
||||
FONT=${FONT%.psf*}
|
||||
inst_opt_decompress ${kbddir}/consolefonts/${FONT}.*
|
||||
fi
|
||||
|
||||
if [[ ${FONT_MAP} ]]
|
||||
then
|
||||
if [[ ${FONT_MAP} ]]; then
|
||||
FONT_MAP=${FONT_MAP%.trans}
|
||||
# There are three different formats that setfont supports
|
||||
inst_simple ${kbddir}/consoletrans/${FONT_MAP} \
|
||||
|| inst_simple ${kbddir}/consoletrans/${FONT_MAP}.trans \
|
||||
|| inst_simple ${kbddir}/consoletrans/${FONT_MAP}_to_uni.trans \
|
||||
|| dwarn "Could not find FONT_MAP ${FONT_MAP}!"
|
||||
|| inst_simple ${kbddir}/consoletrans/${FONT_MAP}.trans \
|
||||
|| inst_simple ${kbddir}/consoletrans/${FONT_MAP}_to_uni.trans \
|
||||
|| dwarn "Could not find FONT_MAP ${FONT_MAP}!"
|
||||
fi
|
||||
|
||||
if [[ ${FONT_UNIMAP} ]]
|
||||
then
|
||||
if [[ ${FONT_UNIMAP} ]]; then
|
||||
FONT_UNIMAP=${FONT_UNIMAP%.uni}
|
||||
inst_simple ${kbddir}/unimaps/${FONT_UNIMAP}.uni
|
||||
fi
|
||||
|
@ -251,8 +241,8 @@ install() {
|
|||
kbddir=''
|
||||
done
|
||||
|
||||
[[ -f $dracutsysrootdir$I18N_CONF && -f $dracutsysrootdir$VCONFIG_CONF ]] || \
|
||||
[[ ! ${hostonly} || ${i18n_vars} ]] || {
|
||||
[[ -f $dracutsysrootdir$I18N_CONF && -f $dracutsysrootdir$VCONFIG_CONF ]] \
|
||||
|| [[ ! ${hostonly} || ${i18n_vars} ]] || {
|
||||
derror 'i18n_vars not set! Please set up i18n_vars in ' \
|
||||
'configuration file.'
|
||||
}
|
||||
|
|
|
@ -4,9 +4,12 @@ inst_key_val() {
|
|||
local _value
|
||||
local _file
|
||||
local _default
|
||||
_file="$1"; shift
|
||||
_key="$1"; shift
|
||||
_default="$1"; shift
|
||||
_file="$1"
|
||||
shift
|
||||
_key="$1"
|
||||
shift
|
||||
_default="$1"
|
||||
shift
|
||||
_value="$(getarg "$@")"
|
||||
[ -z "${_value}" ] && _value=$_default
|
||||
if [ -n "${_value}" ]; then
|
||||
|
@ -16,15 +19,15 @@ inst_key_val() {
|
|||
unset _value
|
||||
}
|
||||
|
||||
inst_key_val /etc/vconsole.conf KEYMAP '' rd.vconsole.keymap KEYMAP -d KEYTABLE
|
||||
inst_key_val /etc/vconsole.conf FONT '' rd.vconsole.font FONT -d SYSFONT
|
||||
inst_key_val /etc/vconsole.conf FONT_MAP '' rd.vconsole.font.map FONT_MAP -d CONTRANS
|
||||
inst_key_val /etc/vconsole.conf FONT_UNIMAP '' rd.vconsole.font.unimap FONT_UNIMAP -d UNIMAP
|
||||
inst_key_val /etc/vconsole.conf UNICODE 1 rd.vconsole.font.unicode UNICODE vconsole.unicode
|
||||
inst_key_val /etc/vconsole.conf EXT_KEYMAP '' rd.vconsole.keymap.ext EXT_KEYMAP
|
||||
inst_key_val /etc/vconsole.conf KEYMAP '' rd.vconsole.keymap KEYMAP -d KEYTABLE
|
||||
inst_key_val /etc/vconsole.conf FONT '' rd.vconsole.font FONT -d SYSFONT
|
||||
inst_key_val /etc/vconsole.conf FONT_MAP '' rd.vconsole.font.map FONT_MAP -d CONTRANS
|
||||
inst_key_val /etc/vconsole.conf FONT_UNIMAP '' rd.vconsole.font.unimap FONT_UNIMAP -d UNIMAP
|
||||
inst_key_val /etc/vconsole.conf UNICODE 1 rd.vconsole.font.unicode UNICODE vconsole.unicode
|
||||
inst_key_val /etc/vconsole.conf EXT_KEYMAP '' rd.vconsole.keymap.ext EXT_KEYMAP
|
||||
|
||||
inst_key_val /etc/locale.conf LANG '' rd.locale.LANG LANG
|
||||
inst_key_val /etc/locale.conf LC_ALL '' rd.locale.LC_ALL LC_ALL
|
||||
inst_key_val /etc/locale.conf LANG '' rd.locale.LANG LANG
|
||||
inst_key_val /etc/locale.conf LC_ALL '' rd.locale.LC_ALL LC_ALL
|
||||
|
||||
if [ -f /etc/locale.conf ]; then
|
||||
. /etc/locale.conf
|
||||
|
|
|
@ -47,7 +47,6 @@ if ! [ -e "$ROOT/usr/bin" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if ! needconvert; then
|
||||
echo "Your system is already converted."
|
||||
exit 0
|
||||
|
@ -82,7 +81,7 @@ find_mount() {
|
|||
|
||||
# usage: ismounted <mountpoint>
|
||||
# usage: ismounted /dev/<device>
|
||||
if command -v findmnt >/dev/null; then
|
||||
if command -v findmnt > /dev/null; then
|
||||
ismounted() {
|
||||
findmnt "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
@ -104,7 +103,7 @@ fi
|
|||
cleanup() {
|
||||
echo "Something failed. Move back to the original state"
|
||||
for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \
|
||||
"$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \
|
||||
"$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \
|
||||
"$ROOT/usr/lib64"; do
|
||||
[[ -d "${dir}.usrmove-new" ]] && rm -fr -- "${dir}.usrmove-new"
|
||||
if [[ -d "${dir}.usrmove-old" ]]; then
|
||||
|
@ -166,8 +165,8 @@ done
|
|||
echo "Clean up backup files."
|
||||
# everything seems to work; cleanup
|
||||
for dir in bin sbin lib lib64; do
|
||||
# if we get killed in the middle of "rm -rf", ensure not to leave
|
||||
# an incomplete directory, which is moved back by cleanup()
|
||||
# if we get killed in the middle of "rm -rf", ensure not to leave
|
||||
# an incomplete directory, which is moved back by cleanup()
|
||||
[[ -d "$ROOT/usr/${dir}.usrmove-old" ]] \
|
||||
&& mv "$ROOT/usr/${dir}.usrmove-old" "$ROOT/usr/${dir}.usrmove-old~"
|
||||
[[ -d "$ROOT/${dir}.usrmove-old" ]] \
|
||||
|
|
|
@ -17,4 +17,3 @@ install() {
|
|||
inst_hook pre-pivot 99 "$moddir/do-convertfs.sh"
|
||||
inst_script "$moddir/convertfs.sh" /usr/bin/convertfs
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh
|
||||
|
||||
# We already need a set netif here
|
||||
netif=$interface
|
||||
|
@ -31,8 +31,8 @@ setup_interface() {
|
|||
# problems with UDP traffic, among other things. As such,
|
||||
# disallow MTUs from 576 and below by default, so that broken
|
||||
# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
|
||||
if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then
|
||||
if ! ip link set $netif mtu $mtu ; then
|
||||
if [ -n "$mtu" ] && [ $mtu -gt 576 ]; then
|
||||
if ! ip link set $netif mtu $mtu; then
|
||||
ip link set $netif down
|
||||
ip link set $netif mtu $mtu
|
||||
linkup $netif
|
||||
|
@ -43,8 +43,8 @@ setup_interface() {
|
|||
${lease_time:+valid_lft $lease_time} \
|
||||
${preferred_lft:+preferred_lft ${preferred_lft}}
|
||||
|
||||
if [ -n "$gw" ] ; then
|
||||
if [ "$mask" = "255.255.255.255" ] ; then
|
||||
if [ -n "$gw" ]; then
|
||||
if [ "$mask" = "255.255.255.255" ]; then
|
||||
# point-to-point connection => set explicit route to gateway
|
||||
echo ip route add $gw dev $netif > /tmp/net.$netif.gw
|
||||
fi
|
||||
|
@ -52,7 +52,7 @@ setup_interface() {
|
|||
echo "$gw" | {
|
||||
IFS=' ' read -r main_gw other_gw
|
||||
echo ip route replace default via $main_gw dev $netif >> /tmp/net.$netif.gw
|
||||
if [ -n "$other_gw" ] ; then
|
||||
if [ -n "$other_gw" ]; then
|
||||
for g in $other_gw; do
|
||||
echo ip route add default via $g dev $netif >> /tmp/net.$netif.gw
|
||||
done
|
||||
|
@ -62,7 +62,7 @@ setup_interface() {
|
|||
|
||||
if getargbool 1 rd.peerdns; then
|
||||
[ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
|
||||
if [ -n "$namesrv" ] ; then
|
||||
if [ -n "$namesrv" ]; then
|
||||
for s in $namesrv; do
|
||||
echo nameserver $s
|
||||
done
|
||||
|
@ -92,7 +92,7 @@ setup_interface6() {
|
|||
|
||||
if getargbool 1 rd.peerdns; then
|
||||
[ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
|
||||
if [ -n "$namesrv" ] ; then
|
||||
if [ -n "$namesrv" ]; then
|
||||
for s in $namesrv; do
|
||||
echo nameserver $s
|
||||
done
|
||||
|
@ -119,13 +119,19 @@ parse_option_121() {
|
|||
# Parse the arguments into a CIDR net/mask string
|
||||
if [ $mask -gt 24 ]; then
|
||||
destination="$1.$2.$3.$4/$mask"
|
||||
shift; shift; shift; shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
elif [ $mask -gt 16 ]; then
|
||||
destination="$1.$2.$3.0/$mask"
|
||||
shift; shift; shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
elif [ $mask -gt 8 ]; then
|
||||
destination="$1.$2.0.0/$mask"
|
||||
shift; shift
|
||||
shift
|
||||
shift
|
||||
elif [ $mask -gt 0 ]; then
|
||||
destination="$1.0.0.0/$mask"
|
||||
shift
|
||||
|
@ -135,7 +141,10 @@ parse_option_121() {
|
|||
|
||||
# Read the gateway
|
||||
gateway="$1.$2.$3.$4"
|
||||
shift; shift; shift; shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
|
||||
# Multicast routing on Linux
|
||||
# - If you set a next-hop address for a multicast group, this breaks with Cisco switches
|
||||
|
@ -150,7 +159,6 @@ parse_option_121() {
|
|||
done
|
||||
}
|
||||
|
||||
|
||||
case $reason in
|
||||
PREINIT)
|
||||
echo "dhcp: PREINIT $netif up"
|
||||
|
@ -170,13 +178,13 @@ case $reason in
|
|||
read layer2 < /sys/class/net/$netif/device/layer2
|
||||
fi
|
||||
if [ "$layer2" != "0" ]; then
|
||||
if command -v arping2 >/dev/null; then
|
||||
if arping2 -q -C 1 -c 2 -I $netif -0 $new_ip_address ; then
|
||||
if command -v arping2 > /dev/null; then
|
||||
if arping2 -q -C 1 -c 2 -I $netif -0 $new_ip_address; then
|
||||
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if ! arping -f -q -D -c 2 -I $netif $new_ip_address ; then
|
||||
if ! arping -f -q -D -c 2 -I $netif $new_ip_address; then
|
||||
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -187,7 +195,7 @@ case $reason in
|
|||
set | while read line || [ -n "$line" ]; do
|
||||
[ "${line#new_}" = "$line" ] && continue
|
||||
echo "$line"
|
||||
done >/tmp/dhclient.$netif.dhcpopts
|
||||
done > /tmp/dhclient.$netif.dhcpopts
|
||||
|
||||
{
|
||||
echo '. /lib/net-lib.sh'
|
||||
|
@ -204,22 +212,22 @@ case $reason in
|
|||
} > $hookdir/initqueue/setup_net_$netif.sh
|
||||
|
||||
echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
|
||||
>/tmp/net.$netif.up
|
||||
> /tmp/net.$netif.up
|
||||
if [ -e /sys/class/net/${netif}/address ]; then
|
||||
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
RENEW|REBIND)
|
||||
RENEW | REBIND)
|
||||
unset lease_time
|
||||
[ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time
|
||||
[ -n "$new_max_life" ] && lease_time=$new_max_life
|
||||
preferred_lft=$lease_time
|
||||
[ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
|
||||
ip -4 addr change ${new_ip_address}/${new_subnet_mask} broadcast ${new_broadcast_address} dev ${interface} \
|
||||
${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
|
||||
>/dev/null 2>&1
|
||||
${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
|
||||
> /dev/null 2>&1
|
||||
;;
|
||||
|
||||
BOUND6)
|
||||
|
@ -229,7 +237,7 @@ case $reason in
|
|||
set | while read line || [ -n "$line" ]; do
|
||||
[ "${line#new_}" = "$line" ] && continue
|
||||
echo "$line"
|
||||
done >/tmp/dhclient.$netif.dhcpopts
|
||||
done > /tmp/dhclient.$netif.dhcpopts
|
||||
|
||||
{
|
||||
echo '. /lib/net-lib.sh'
|
||||
|
@ -240,24 +248,24 @@ case $reason in
|
|||
} > $hookdir/initqueue/setup_net_$netif.sh
|
||||
|
||||
echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
|
||||
>/tmp/net.$netif.up
|
||||
> /tmp/net.$netif.up
|
||||
if [ -e /sys/class/net/${netif}/address ]; then
|
||||
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
|
||||
fi
|
||||
;;
|
||||
|
||||
RENEW6|REBIND6)
|
||||
RENEW6 | REBIND6)
|
||||
unset lease_time
|
||||
[ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time
|
||||
[ -n "$new_max_life" ] && lease_time=$new_max_life
|
||||
preferred_lft=$lease_time
|
||||
[ -n "$new_preferred_life" ] && preferred_lft=$new_preferred_life
|
||||
ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} dev ${interface} scope global \
|
||||
${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
|
||||
>/dev/null 2>&1
|
||||
${lease_time:+valid_lft $lease_time} ${preferred_lft:+preferred_lft ${preferred_lft}} \
|
||||
> /dev/null 2>&1
|
||||
;;
|
||||
|
||||
*) echo "dhcp: $reason";;
|
||||
*) echo "dhcp: $reason" ;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -23,14 +23,14 @@ do_dhclient() {
|
|||
while [ $_COUNT -lt $_DHCPRETRY ]; do
|
||||
info "Starting dhcp for interface $netif"
|
||||
dhclient $arg \
|
||||
${_timeout:+--timeout $_timeout} \
|
||||
-q \
|
||||
-1 \
|
||||
-cf /etc/dhclient.conf \
|
||||
-pf /tmp/dhclient.$netif.pid \
|
||||
-lf /tmp/dhclient.$netif.lease \
|
||||
$netif &
|
||||
wait $! 2>/dev/null
|
||||
${_timeout:+--timeout $_timeout} \
|
||||
-q \
|
||||
-1 \
|
||||
-cf /etc/dhclient.conf \
|
||||
-pf /tmp/dhclient.$netif.pid \
|
||||
-lf /tmp/dhclient.$netif.lease \
|
||||
$netif &
|
||||
wait $! 2> /dev/null
|
||||
|
||||
# wait will return the return value of dhclient
|
||||
retv=$?
|
||||
|
@ -45,7 +45,7 @@ do_dhclient() {
|
|||
# find the process with that pid and return error code 127. In that
|
||||
# case we need to check if /tmp/dhclient.$netif.lease exists. If it
|
||||
# does, it means dhclient finished executing before wait was called,
|
||||
# and it was successful (return 0). If /tmp/dhclient.$netif.lease
|
||||
# and it was successful (return 0). If /tmp/dhclient.$netif.lease
|
||||
# does not exist, then it means dhclient was killed by another thread
|
||||
# or it finished execution but failed dhcp on that interface.
|
||||
|
||||
|
@ -56,14 +56,14 @@ do_dhclient() {
|
|||
info "PID $pid not found but DHCP successful on $netif"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
_COUNT=$(($_COUNT+1))
|
||||
_COUNT=$(($_COUNT + 1))
|
||||
[ $_COUNT -lt $_DHCPRETRY ] && sleep 1
|
||||
done
|
||||
warn "dhcp for interface $netif failed"
|
||||
# nuke those files since we failed; we might retry dhcp again if it's e.g.
|
||||
# `ip=dhcp,dhcp6` and we check for the PID file earlier
|
||||
# `ip=dhcp,dhcp6` and we check for the PID file earlier
|
||||
rm -f /tmp/dhclient.$netif.{pid,lease}
|
||||
return 1
|
||||
}
|
||||
|
@ -85,15 +85,15 @@ if [ $ret -eq 0 ]; then
|
|||
fi
|
||||
|
||||
# Check if DHCP also suceeded on another interface before this one.
|
||||
# We will always use the first one on which DHCP succeeded, by using
|
||||
# We will always use the first one on which DHCP succeeded, by using
|
||||
# a commom file $IFNETFILE, to synchronize between threads.
|
||||
# Consider the race condition in which multiple threads
|
||||
# Consider the race condition in which multiple threads
|
||||
# corresponding to different interfaces may try to read $IFNETFILE
|
||||
# and find it does not exist; they may all end up thinking they are the
|
||||
# first to succeed (hence more than one thread may end up writing to
|
||||
# $IFNETFILE). To take care of this, instead of checking if $IFNETFILE
|
||||
# $IFNETFILE). To take care of this, instead of checking if $IFNETFILE
|
||||
# exists to determine if we are the first, we create a symbolic link
|
||||
# in $IFNETFILE, pointing to the interface name ($netif), thus storing
|
||||
# in $IFNETFILE, pointing to the interface name ($netif), thus storing
|
||||
# the interface name in the link pointer.
|
||||
# Creating a link will fail, if the link already exists, hence kernel
|
||||
# will take care of allowing only first thread to create link, which
|
||||
|
@ -101,22 +101,22 @@ if [ $ret -eq 0 ]; then
|
|||
# Also, the link points to the interface name, which will tell us which
|
||||
# interface succeeded.
|
||||
|
||||
if ln -s $netif $IFNETFILE 2>/dev/null; then
|
||||
if ln -s $netif $IFNETFILE 2> /dev/null; then
|
||||
intf=$(readlink $IFNETFILE)
|
||||
if [ -e /tmp/dhclient.$intf.lease ]; then
|
||||
info "DHCP successful on interface $intf"
|
||||
# Kill all existing dhclient calls for other interfaces, since we
|
||||
# Kill all existing dhclient calls for other interfaces, since we
|
||||
# already got one successful interface
|
||||
|
||||
npid=$(cat /tmp/dhclient.$netif.pid)
|
||||
pidlist=$(pgrep dhclient)
|
||||
for pid in $pidlist; do
|
||||
[ "$pid" -eq "$npid" ] && continue
|
||||
kill -9 $pid >/dev/null 2>&1
|
||||
kill -9 $pid > /dev/null 2>&1
|
||||
done
|
||||
else
|
||||
echo "ERROR! $IFNETFILE exists but /tmp/dhclient.$intf.lease does not exist!!!"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
info "DHCP success on $netif, and also on $intf"
|
||||
exit 0
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
# or it is for manually bring up network ie. for kdump scp vmcore
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type ip_to_var > /dev/null 2>&1 || . /lib/net-lib.sh
|
||||
|
||||
# Huh? No $1?
|
||||
[ -z "$1" ] && exit 1
|
||||
|
@ -17,7 +17,7 @@ type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
|
|||
netif=$1
|
||||
|
||||
# loopback is always handled the same way
|
||||
if [ "$netif" = "lo" ] ; then
|
||||
if [ "$netif" = "lo" ]; then
|
||||
ip link set lo up
|
||||
ip addr add 127.0.0.1/8 dev lo
|
||||
exit 0
|
||||
|
@ -36,15 +36,15 @@ do_dhcp_parallel() {
|
|||
fi
|
||||
|
||||
bootintf=$(readlink $IFNETFILE)
|
||||
if [ ! -z $bootintf ] && [ -e /tmp/dhclient.$bootintf.lease ]; then
|
||||
if [ ! -z $bootintf ] && [ -e /tmp/dhclient.$bootintf.lease ]; then
|
||||
info "DHCP already succeeded for $bootintf, exiting for $netif"
|
||||
return 1;
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -e /run/NetworkManager/conf.d/10-dracut-dhclient.conf ]; then
|
||||
mkdir -p /run/NetworkManager/conf.d
|
||||
echo '[main]' > /run/NetworkManager/conf.d/10-dracut-dhclient.conf
|
||||
echo 'dhcp=dhclient' >>/run/NetworkManager/conf.d/10-dracut-dhclient.conf
|
||||
echo 'dhcp=dhclient' >> /run/NetworkManager/conf.d/10-dracut-dhclient.conf
|
||||
fi
|
||||
|
||||
chmod +x /sbin/dhcp-multi.sh
|
||||
|
@ -73,21 +73,21 @@ do_dhcp() {
|
|||
if [ ! -e /run/NetworkManager/conf.d/10-dracut-dhclient.conf ]; then
|
||||
mkdir -p /run/NetworkManager/conf.d
|
||||
echo '[main]' > /run/NetworkManager/conf.d/10-dracut-dhclient.conf
|
||||
echo 'dhcp=dhclient' >>/run/NetworkManager/conf.d/10-dracut-dhclient.conf
|
||||
echo 'dhcp=dhclient' >> /run/NetworkManager/conf.d/10-dracut-dhclient.conf
|
||||
fi
|
||||
|
||||
while [ $_COUNT -lt $_DHCPRETRY ]; do
|
||||
info "Starting dhcp for interface $netif"
|
||||
dhclient "$@" \
|
||||
${_timeout:+--timeout $_timeout} \
|
||||
-q \
|
||||
-1 \
|
||||
-cf /etc/dhclient.conf \
|
||||
-pf /tmp/dhclient.$netif.pid \
|
||||
-lf /tmp/dhclient.$netif.lease \
|
||||
$netif \
|
||||
${_timeout:+--timeout $_timeout} \
|
||||
-q \
|
||||
-1 \
|
||||
-cf /etc/dhclient.conf \
|
||||
-pf /tmp/dhclient.$netif.pid \
|
||||
-lf /tmp/dhclient.$netif.lease \
|
||||
$netif \
|
||||
&& return 0
|
||||
_COUNT=$(($_COUNT+1))
|
||||
_COUNT=$(($_COUNT + 1))
|
||||
[ $_COUNT -lt $_DHCPRETRY ] && sleep 1
|
||||
done
|
||||
warn "dhcp for interface $netif failed"
|
||||
|
@ -102,7 +102,7 @@ load_ipv6() {
|
|||
modprobe ipv6
|
||||
i=0
|
||||
while [ ! -d /proc/sys/net/ipv6 ]; do
|
||||
i=$(($i+1))
|
||||
i=$(($i + 1))
|
||||
[ $i -gt 10 ] && break
|
||||
sleep 0.1
|
||||
done
|
||||
|
@ -148,7 +148,7 @@ do_static() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
ip route get "$ip" 2>/dev/null | {
|
||||
ip route get "$ip" 2> /dev/null | {
|
||||
read a rest
|
||||
if [ "$a" = "local" ]; then
|
||||
warn "Not assigning $ip to interface $netif, cause it is already assigned!"
|
||||
|
@ -168,13 +168,13 @@ do_static() {
|
|||
wait_for_ipv6_dad $netif
|
||||
else
|
||||
if [ -z "$srv" ]; then
|
||||
if command -v arping2 >/dev/null; then
|
||||
if arping2 -q -C 1 -c 2 -I $netif -0 $ip ; then
|
||||
if command -v arping2 > /dev/null; then
|
||||
if arping2 -q -C 1 -c 2 -I $netif -0 $ip; then
|
||||
warn "Duplicate address detected for $ip for interface $netif."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if ! arping -f -q -D -c 2 -I $netif $ip ; then
|
||||
if ! arping -f -q -D -c 2 -I $netif $ip; then
|
||||
warn "Duplicate address detected for $ip for interface $netif."
|
||||
return 1
|
||||
fi
|
||||
|
@ -192,12 +192,12 @@ do_static() {
|
|||
|
||||
get_vid() {
|
||||
case "$1" in
|
||||
vlan*)
|
||||
echo ${1#vlan}
|
||||
;;
|
||||
*.*)
|
||||
echo ${1##*.}
|
||||
;;
|
||||
vlan*)
|
||||
echo ${1#vlan}
|
||||
;;
|
||||
*.*)
|
||||
echo ${1##*.}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,6 @@ if ! [ -e /tmp/vlan.${netif}.phy ]; then
|
|||
done
|
||||
fi
|
||||
|
||||
|
||||
# bridge this interface?
|
||||
if [ -z "$NO_BRIDGE_MASTER" ]; then
|
||||
for i in /tmp/bridge.*.info; do
|
||||
|
@ -238,7 +237,7 @@ if [ -z "$NO_BRIDGE_MASTER" ]; then
|
|||
unset bridgeslaves
|
||||
unset bridgename
|
||||
. "$i"
|
||||
for ethname in $bridgeslaves ; do
|
||||
for ethname in $bridgeslaves; do
|
||||
[ "$netif" != "$ethname" ] && continue
|
||||
|
||||
NO_BRIDGE_MASTER=yes NO_AUTO_DHCP=yes ifup $ethname
|
||||
|
@ -262,40 +261,40 @@ if [ -z "$NO_BOND_MASTER" ]; then
|
|||
unset bondslaves
|
||||
unset bondname
|
||||
. "$i"
|
||||
for slave in $bondslaves ; do
|
||||
for slave in $bondslaves; do
|
||||
[ "$netif" != "$slave" ] && continue
|
||||
|
||||
# already setup
|
||||
[ -e /tmp/bond.$bondname.up ] && exit 0
|
||||
|
||||
# wait for all slaves to show up
|
||||
for slave in $bondslaves ; do
|
||||
for slave in $bondslaves; do
|
||||
# try to create the slave (maybe vlan or bridge)
|
||||
NO_BOND_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
|
||||
|
||||
if ! ip link show dev $slave >/dev/null 2>&1; then
|
||||
if ! ip link show dev $slave > /dev/null 2>&1; then
|
||||
# wait for the last slave to show up
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
modprobe -q -b bonding
|
||||
echo "+$bondname" > /sys/class/net/bonding_masters 2>/dev/null
|
||||
echo "+$bondname" > /sys/class/net/bonding_masters 2> /dev/null
|
||||
ip link set $bondname down
|
||||
|
||||
# Stolen from ifup-eth
|
||||
# add the bits to setup driver parameters here
|
||||
for arg in $bondoptions ; do
|
||||
key=${arg%%=*};
|
||||
value=${arg##*=};
|
||||
for arg in $bondoptions; do
|
||||
key=${arg%%=*}
|
||||
value=${arg##*=}
|
||||
# %{value:0:1} is replaced with non-bash specific construct
|
||||
if [ "${key}" = "arp_ip_target" -a "${#value}" != "0" -a "+${value%%+*}" != "+" ]; then
|
||||
OLDIFS=$IFS;
|
||||
IFS=',';
|
||||
OLDIFS=$IFS
|
||||
IFS=','
|
||||
for arp_ip in $value; do
|
||||
echo +$arp_ip > /sys/class/net/${bondname}/bonding/$key
|
||||
done
|
||||
IFS=$OLDIFS;
|
||||
IFS=$OLDIFS
|
||||
else
|
||||
echo $value > /sys/class/net/${bondname}/bonding/$key
|
||||
fi
|
||||
|
@ -303,7 +302,7 @@ if [ -z "$NO_BOND_MASTER" ]; then
|
|||
|
||||
linkup $bondname
|
||||
|
||||
for slave in $bondslaves ; do
|
||||
for slave in $bondslaves; do
|
||||
cat /sys/class/net/$slave/address > /tmp/net.${bondname}.${slave}.hwaddr
|
||||
ip link set $slave down
|
||||
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
|
||||
|
@ -314,9 +313,9 @@ if [ -z "$NO_BOND_MASTER" ]; then
|
|||
[ -n "$bondmtu" ] && ip link set mtu $bondmtu dev $bondname
|
||||
|
||||
# add the bits to setup the needed post enslavement parameters
|
||||
for arg in $bondoptions ; do
|
||||
key=${arg%%=*};
|
||||
value=${arg##*=};
|
||||
for arg in $bondoptions; do
|
||||
key=${arg%%=*}
|
||||
value=${arg##*=}
|
||||
if [ "${key}" = "primary" ]; then
|
||||
echo $value > /sys/class/net/${bondname}/bonding/$key
|
||||
fi
|
||||
|
@ -336,30 +335,30 @@ if [ -z "$NO_TEAM_MASTER" ]; then
|
|||
unset teammaster
|
||||
unset teamslaves
|
||||
. "$i"
|
||||
for slave in $teamslaves ; do
|
||||
for slave in $teamslaves; do
|
||||
[ "$netif" != "$slave" ] && continue
|
||||
|
||||
[ -e /tmp/team.$teammaster.up ] && exit 0
|
||||
|
||||
# wait for all slaves to show up
|
||||
for slave in $teamslaves ; do
|
||||
for slave in $teamslaves; do
|
||||
# try to create the slave (maybe vlan or bridge)
|
||||
NO_TEAM_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
|
||||
|
||||
if ! ip link show dev $slave >/dev/null 2>&1; then
|
||||
if ! ip link show dev $slave > /dev/null 2>&1; then
|
||||
# wait for the last slave to show up
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -e /tmp/team.$teammaster.up ] ; then
|
||||
if [ ! -e /tmp/team.$teammaster.up ]; then
|
||||
# We shall only bring up those _can_ come up
|
||||
# in case of some slave is gone in active-backup mode
|
||||
working_slaves=""
|
||||
for slave in $teamslaves ; do
|
||||
teamdctl ${teammaster} port present ${slave} 2>/dev/null \
|
||||
for slave in $teamslaves; do
|
||||
teamdctl ${teammaster} port present ${slave} 2> /dev/null \
|
||||
&& continue
|
||||
ip link set dev $slave up 2>/dev/null
|
||||
ip link set dev $slave up 2> /dev/null
|
||||
if wait_for_if_up $slave; then
|
||||
working_slaves="$working_slaves$slave "
|
||||
fi
|
||||
|
@ -399,7 +398,7 @@ if [ -z "$NO_TEAM_MASTER" ]; then
|
|||
fi
|
||||
|
||||
# all synthetic interfaces done.. now check if the interface is available
|
||||
if ! ip link show dev $netif >/dev/null 2>&1; then
|
||||
if ! ip link show dev $netif > /dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -408,16 +407,15 @@ fi
|
|||
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
|
||||
|
||||
if [ -n "$manualup" ]; then
|
||||
>/tmp/net.$netif.manualup
|
||||
> /tmp/net.$netif.manualup
|
||||
rm -f /tmp/net.${netif}.did-setup
|
||||
else
|
||||
[ -e /tmp/net.${netif}.did-setup ] && exit 0
|
||||
[ -z "$DO_VLAN" ] && \
|
||||
[ -e /sys/class/net/$netif/address ] && \
|
||||
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
|
||||
[ -z "$DO_VLAN" ] \
|
||||
&& [ -e /sys/class/net/$netif/address ] \
|
||||
&& [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Specific configuration, spin through the kernel command line
|
||||
# looking for ip= lines
|
||||
for p in $(getargs ip=); do
|
||||
|
@ -426,11 +424,11 @@ for p in $(getargs ip=); do
|
|||
[ "$autoconf" = "ibft" ] && continue
|
||||
|
||||
case "$dev" in
|
||||
??:??:??:??:??:??) # MAC address
|
||||
??:??:??:??:??:??) # MAC address
|
||||
_dev=$(iface_for_mac $dev)
|
||||
[ -n "$_dev" ] && dev="$_dev"
|
||||
;;
|
||||
??-??-??-??-??-??) # MAC address in BOOTIF form
|
||||
??-??-??-??-??-??) # MAC address in BOOTIF form
|
||||
_dev=$(iface_for_mac $(fix_bootif $dev))
|
||||
[ -n "$_dev" ] && dev="$_dev"
|
||||
;;
|
||||
|
@ -450,22 +448,29 @@ for p in $(getargs ip=); do
|
|||
|
||||
for autoopt in $(str_replace "$autoconf" "," " "); do
|
||||
case $autoopt in
|
||||
dhcp|on|any)
|
||||
do_dhcp -4 ;;
|
||||
dhcp | on | any)
|
||||
do_dhcp -4
|
||||
;;
|
||||
single-dhcp)
|
||||
do_dhcp_parallel -4
|
||||
exit 0 ;;
|
||||
exit 0
|
||||
;;
|
||||
dhcp6)
|
||||
load_ipv6
|
||||
do_dhcp -6 ;;
|
||||
do_dhcp -6
|
||||
;;
|
||||
auto6)
|
||||
do_ipv6auto ;;
|
||||
do_ipv6auto
|
||||
;;
|
||||
either6)
|
||||
do_ipv6auto || do_dhcp -6 ;;
|
||||
do_ipv6auto || do_dhcp -6
|
||||
;;
|
||||
link6)
|
||||
do_ipv6link ;;
|
||||
do_ipv6link
|
||||
;;
|
||||
*)
|
||||
do_static ;;
|
||||
do_static
|
||||
;;
|
||||
esac
|
||||
done
|
||||
ret=$?
|
||||
|
@ -479,7 +484,7 @@ for p in $(getargs ip=); do
|
|||
if [ $ret -eq 0 ]; then
|
||||
> /tmp/net.${netif}.up
|
||||
|
||||
if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
|
||||
if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
|
||||
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
|
||||
fi
|
||||
|
||||
|
@ -493,7 +498,7 @@ for p in $(getargs ip=); do
|
|||
fi
|
||||
fi
|
||||
|
||||
if command -v wicked >/dev/null && [ -z "$manualup" ]; then
|
||||
if command -v wicked > /dev/null && [ -z "$manualup" ]; then
|
||||
/sbin/netroot $netif
|
||||
fi
|
||||
|
||||
|
@ -514,12 +519,12 @@ if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then
|
|||
# No ip lines, no bootdev -> default to dhcp
|
||||
ip=$(getarg ip)
|
||||
|
||||
if getargs 'ip=dhcp6' >/dev/null || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then
|
||||
if getargs 'ip=dhcp6' > /dev/null || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then
|
||||
load_ipv6
|
||||
do_dhcp -6
|
||||
ret=$?
|
||||
fi
|
||||
if getargs 'ip=dhcp' >/dev/null || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then
|
||||
if getargs 'ip=dhcp' > /dev/null || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then
|
||||
do_dhcp -4
|
||||
ret=$?
|
||||
fi
|
||||
|
@ -530,11 +535,11 @@ if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then
|
|||
echo nameserver $s >> /tmp/net.$netif.resolv.conf
|
||||
done
|
||||
|
||||
if [ "$ret" -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}* 2>/dev/null)" ]; then
|
||||
> /tmp/net.${netif}.did-setup
|
||||
if [ -e /sys/class/net/${netif}/address ]; then
|
||||
> /tmp/net.$(cat /sys/class/net/${netif}/address).did-setup
|
||||
fi
|
||||
if [ "$ret" -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}* 2> /dev/null)" ]; then
|
||||
> /tmp/net.${netif}.did-setup
|
||||
if [ -e /sys/class/net/${netif}/address ]; then
|
||||
> /tmp/net.$(cat /sys/class/net/${netif}/address).did-setup
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
for f in /tmp/dhclient.*.pid; do
|
||||
[ -e $f ] || continue
|
||||
read PID < $f;
|
||||
kill $PID >/dev/null 2>&1
|
||||
read PID < $f
|
||||
kill $PID > /dev/null 2>&1
|
||||
done
|
||||
|
||||
sleep 0.1
|
||||
|
||||
for f in /tmp/dhclient.*.pid; do
|
||||
[ -e $f ] || continue
|
||||
read PID < $f;
|
||||
kill -9 $PID >/dev/null 2>&1
|
||||
read PID < $f
|
||||
kill -9 $PID > /dev/null 2>&1
|
||||
done
|
||||
|
|
|
@ -62,7 +62,7 @@ install() {
|
|||
(
|
||||
. "$i"
|
||||
if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \
|
||||
&& [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then
|
||||
&& [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then
|
||||
if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then
|
||||
mkdir -p $initdir/etc/teamd
|
||||
printf -- "%s" "$TEAM_CONFIG" > "$initdir/etc/teamd/${DEVICE}.conf"
|
||||
|
@ -90,4 +90,3 @@ install() {
|
|||
|
||||
dracut_need_initqueue
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ if [ -z "$netroot" ] && [ ! -e "/tmp/net.ifaces" ] && [ "$NEEDNET" != "1" ]; the
|
|||
return
|
||||
fi
|
||||
|
||||
command -v fix_bootif >/dev/null || . /lib/net-lib.sh
|
||||
command -v fix_bootif > /dev/null || . /lib/net-lib.sh
|
||||
|
||||
# Write udev rules
|
||||
{
|
||||
|
@ -75,15 +75,15 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
|
|||
echo 'ACTION!="add|change|move", GOTO="net_end"'
|
||||
for iface in $IFACES $RAW_IFACES; do
|
||||
case "$iface" in
|
||||
??:??:??:??:??:??) # MAC address
|
||||
??:??:??:??:??:??) # MAC address
|
||||
cond="ATTR{address}==\"$iface\""
|
||||
echo "$cond, $runcmd, GOTO=\"net_end\""
|
||||
;;
|
||||
??-??-??-??-??-??) # MAC address in BOOTIF form
|
||||
??-??-??-??-??-??) # MAC address in BOOTIF form
|
||||
cond="ATTR{address}==\"$(fix_bootif $iface)\""
|
||||
echo "$cond, $runcmd, GOTO=\"net_end\""
|
||||
;;
|
||||
*) # an interface name
|
||||
*) # an interface name
|
||||
cond="ENV{INTERFACE}==\"$iface\""
|
||||
echo "$cond, $runcmd, GOTO=\"net_end\""
|
||||
cond="NAME==\"$iface\""
|
||||
|
@ -96,11 +96,11 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
|
|||
|
||||
for iface in $IFACES; do
|
||||
if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then
|
||||
if [ -n "$netroot" ] && [ -n "$DRACUT_SYSTEMD" ]; then
|
||||
if [ -n "$netroot" ] && [ -n "$DRACUT_SYSTEMD" ]; then
|
||||
echo "systemctl is-active initrd-root-device.target || [ -f /tmp/net.${iface}.did-setup ]"
|
||||
else
|
||||
else
|
||||
echo "[ -f /tmp/net.${iface}.did-setup ]"
|
||||
fi >$hookdir/initqueue/finished/wait-$iface.sh
|
||||
fi > $hookdir/initqueue/finished/wait-$iface.sh
|
||||
fi
|
||||
done
|
||||
# Default: We don't know the interface to use, handle all
|
||||
|
@ -110,9 +110,9 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
|
|||
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
|
||||
echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
|
||||
if [ "$NEEDNET" = "1" ]; then
|
||||
echo 'for i in /tmp/net.*.did-setup; do [ -f "$i" ] && exit 0; done; exit 1' >$hookdir/initqueue/finished/wait-network.sh
|
||||
echo 'for i in /tmp/net.*.did-setup; do [ -f "$i" ] && exit 0; done; exit 1' > $hookdir/initqueue/finished/wait-network.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
# if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
|
||||
# if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
|
||||
} > /etc/udev/rules.d/90-net.rules
|
||||
|
|
|
@ -23,12 +23,30 @@ parsebond() {
|
|||
done
|
||||
|
||||
case $# in
|
||||
0) bondname=bond0; bondslaves="eth0 eth1" ;;
|
||||
1) bondname=$1; bondslaves="eth0 eth1" ;;
|
||||
2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
|
||||
3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
|
||||
4) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " "); bondmtu=$4;;
|
||||
*) die "bond= requires zero to four parameters" ;;
|
||||
0)
|
||||
bondname=bond0
|
||||
bondslaves="eth0 eth1"
|
||||
;;
|
||||
1)
|
||||
bondname=$1
|
||||
bondslaves="eth0 eth1"
|
||||
;;
|
||||
2)
|
||||
bondname=$1
|
||||
bondslaves=$(str_replace "$2" "," " ")
|
||||
;;
|
||||
3)
|
||||
bondname=$1
|
||||
bondslaves=$(str_replace "$2" "," " ")
|
||||
bondoptions=$(str_replace "$3" "," " ")
|
||||
;;
|
||||
4)
|
||||
bondname=$1
|
||||
bondslaves=$(str_replace "$2" "," " ")
|
||||
bondoptions=$(str_replace "$3" "," " ")
|
||||
bondmtu=$4
|
||||
;;
|
||||
*) die "bond= requires zero to four parameters" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,16 @@ parsebridge() {
|
|||
v=${v#*:}
|
||||
done
|
||||
case $# in
|
||||
0) bridgename=br0; bridgeslaves=$iface ;;
|
||||
1) die "bridge= requires two parameters" ;;
|
||||
2) bridgename=$1; bridgeslaves=$(str_replace "$2" "," " ") ;;
|
||||
*) die "bridge= requires two parameters" ;;
|
||||
0)
|
||||
bridgename=br0
|
||||
bridgeslaves=$iface
|
||||
;;
|
||||
1) die "bridge= requires two parameters" ;;
|
||||
2)
|
||||
bridgename=$1
|
||||
bridgeslaves=$(str_replace "$2" "," " ")
|
||||
;;
|
||||
*) die "bridge= requires two parameters" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v ibft_to_cmdline >/dev/null || . /lib/net-lib.sh
|
||||
command -v getarg > /dev/null || . /lib/dracut-lib.sh
|
||||
command -v ibft_to_cmdline > /dev/null || . /lib/net-lib.sh
|
||||
|
||||
if getargbool 0 rd.iscsi.ibft -d "ip=ibft"; then
|
||||
modprobe -b -q iscsi_boot_sysfs 2>/dev/null
|
||||
modprobe -b -q iscsi_boot_sysfs 2> /dev/null
|
||||
modprobe -b -q iscsi_ibft
|
||||
ibft_to_cmdline
|
||||
fi
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
# an ifname= argument for each interface used in an ip= or fcoe= argument
|
||||
|
||||
# check if there are any ifname parameters
|
||||
if ! getarg ifname= >/dev/null ; then
|
||||
if ! getarg ifname= > /dev/null; then
|
||||
return
|
||||
fi
|
||||
|
||||
command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
|
||||
command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh
|
||||
|
||||
# Check ifname= lines
|
||||
for p in $(getargs ifname=); do
|
||||
|
|
|
@ -12,22 +12,23 @@
|
|||
# routing,dns,dhcp-options,etc.
|
||||
#
|
||||
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v getarg > /dev/null || . /lib/dracut-lib.sh
|
||||
|
||||
if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] && [ -z "$(getarg BOOTIF=)" ]; then
|
||||
# No ip= argument(s) for netroot provided, defaulting to DHCP
|
||||
return;
|
||||
return
|
||||
fi
|
||||
|
||||
# Count ip= lines to decide whether we need bootdev= or not
|
||||
if [ -z "$NEEDBOOTDEV" ] ; then
|
||||
if [ -z "$NEEDBOOTDEV" ]; then
|
||||
count=0
|
||||
for p in $(getargs ip=); do
|
||||
case "$p" in
|
||||
ibft)
|
||||
continue;;
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
count=$(( $count + 1 ))
|
||||
count=$(($count + 1))
|
||||
done
|
||||
[ $count -gt 1 ] && NEEDBOOTDEV=1
|
||||
fi
|
||||
|
@ -59,7 +60,7 @@ for p in $(getargs ip=); do
|
|||
[ "$autoconf" = "ibft" ] && continue
|
||||
|
||||
# Empty autoconf defaults to 'dhcp'
|
||||
if [ -z "$autoconf" ] ; then
|
||||
if [ -z "$autoconf" ]; then
|
||||
warn "Empty autoconf values default to dhcp"
|
||||
autoconf="dhcp"
|
||||
fi
|
||||
|
@ -67,30 +68,30 @@ for p in $(getargs ip=); do
|
|||
# Error checking for autoconf in combination with other values
|
||||
for autoopt in $(str_replace "$autoconf" "," " "); do
|
||||
case $autoopt in
|
||||
error) die "Error parsing option 'ip=$p'";;
|
||||
bootp|rarp|both) die "Sorry, ip=$autoopt is currenty unsupported";;
|
||||
none|off)
|
||||
[ -z "$ip" ] && \
|
||||
die "For argument 'ip=$p'\nValue '$autoopt' without static configuration does not make sense"
|
||||
[ -z "$mask" ] && \
|
||||
die "Sorry, automatic calculation of netmask is not yet supported"
|
||||
error) die "Error parsing option 'ip=$p'" ;;
|
||||
bootp | rarp | both) die "Sorry, ip=$autoopt is currenty unsupported" ;;
|
||||
none | off)
|
||||
[ -z "$ip" ] \
|
||||
&& die "For argument 'ip=$p'\nValue '$autoopt' without static configuration does not make sense"
|
||||
[ -z "$mask" ] \
|
||||
&& die "Sorry, automatic calculation of netmask is not yet supported"
|
||||
;;
|
||||
auto6|link6);;
|
||||
either6);;
|
||||
dhcp|dhcp6|on|any|single-dhcp) \
|
||||
[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
|
||||
die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
|
||||
[ -n "$ip" ] && \
|
||||
die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'"
|
||||
auto6 | link6) ;;
|
||||
either6) ;;
|
||||
dhcp | dhcp6 | on | any | single-dhcp)
|
||||
[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] \
|
||||
&& die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
|
||||
[ -n "$ip" ] \
|
||||
&& die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'"
|
||||
;;
|
||||
*) die "For argument 'ip=$p'\nSorry, unknown value '$autoopt'";;
|
||||
*) die "For argument 'ip=$p'\nSorry, unknown value '$autoopt'" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "$dev" ] ; then
|
||||
if [ -n "$dev" ]; then
|
||||
# We don't like duplicate device configs
|
||||
if [ -n "$IFACES" ] ; then
|
||||
for i in $IFACES ; do
|
||||
if [ -n "$IFACES" ]; then
|
||||
for i in $IFACES; do
|
||||
[ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'"
|
||||
done
|
||||
fi
|
||||
|
@ -99,7 +100,7 @@ for p in $(getargs ip=); do
|
|||
fi
|
||||
|
||||
# Do we need to check for specific options?
|
||||
if [ -n "$NEEDDHCP" ] || [ -n "$DHCPORSERVER" ] ; then
|
||||
if [ -n "$NEEDDHCP" ] || [ -n "$DHCPORSERVER" ]; then
|
||||
# Correct device? (Empty is ok as well)
|
||||
[ "$dev" = "$BOOTDEV" ] || continue
|
||||
# Server-ip is there?
|
||||
|
@ -113,13 +114,13 @@ for p in $(getargs ip=); do
|
|||
|
||||
if str_starts "$dev" "enx" && [ ${#dev} -eq 15 ]; then
|
||||
printf -- "ifname=%s:%s:%s:%s:%s:%s:%s\n" \
|
||||
"$dev" \
|
||||
"${dev:3:2}" \
|
||||
"${dev:5:2}" \
|
||||
"${dev:7:2}" \
|
||||
"${dev:9:2}" \
|
||||
"${dev:11:2}" \
|
||||
"${dev:13:2}" >> /etc/cmdline.d/80-enx.conf
|
||||
"$dev" \
|
||||
"${dev:3:2}" \
|
||||
"${dev:5:2}" \
|
||||
"${dev:7:2}" \
|
||||
"${dev:9:2}" \
|
||||
"${dev:11:2}" \
|
||||
"${dev:13:2}" >> /etc/cmdline.d/80-enx.conf
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -130,11 +131,11 @@ if getargbool 1 "rd.bootif" && BOOTIF="$(getarg BOOTIF=)"; then
|
|||
fi
|
||||
|
||||
# This ensures that BOOTDEV is always first in IFACES
|
||||
if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then
|
||||
if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ]; then
|
||||
IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}"
|
||||
IFACES="$BOOTDEV $IFACES"
|
||||
fi
|
||||
|
||||
# Store BOOTDEV and IFACES for later use
|
||||
[ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev
|
||||
[ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces
|
||||
[ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces
|
||||
|
|
|
@ -18,11 +18,27 @@ parseteam() {
|
|||
done
|
||||
|
||||
case $# in
|
||||
0) teammaster=team0; teamslaves="eth0 eth1"; teamrunner="activebackup" ;;
|
||||
1) teammaster=$1; teamslaves="eth0 eth1"; teamrunner="activebackup" ;;
|
||||
2) teammaster=$1; teamslaves=$(str_replace "$2" "," " "); teamrunner="activebackup" ;;
|
||||
3) teammaster=$1; teamslaves=$(str_replace "$2" "," " "); teamrunner=$3 ;;
|
||||
*) die "team= requires zero to three parameters" ;;
|
||||
0)
|
||||
teammaster=team0
|
||||
teamslaves="eth0 eth1"
|
||||
teamrunner="activebackup"
|
||||
;;
|
||||
1)
|
||||
teammaster=$1
|
||||
teamslaves="eth0 eth1"
|
||||
teamrunner="activebackup"
|
||||
;;
|
||||
2)
|
||||
teammaster=$1
|
||||
teamslaves=$(str_replace "$2" "," " ")
|
||||
teamrunner="activebackup"
|
||||
;;
|
||||
3)
|
||||
teammaster=$1
|
||||
teamslaves=$(str_replace "$2" "," " ")
|
||||
teamrunner=$3
|
||||
;;
|
||||
*) die "team= requires zero to three parameters" ;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
@ -46,4 +62,3 @@ for team in $(getargs team); do
|
|||
printf -- "%s" "{\"runner\": {\"name\": \"$teamrunner\"}, \"link_watch\": {\"name\": \"ethtool\"}}" > "/tmp/${teammaster}.conf"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -14,8 +14,11 @@ parsevlan() {
|
|||
|
||||
unset vlanname phydevice
|
||||
case $# in
|
||||
2) vlanname=$1; phydevice=$2 ;;
|
||||
*) die "vlan= requires two parameters" ;;
|
||||
2)
|
||||
vlanname=$1
|
||||
phydevice=$2
|
||||
;;
|
||||
*) die "vlan= requires two parameters" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
type nm_generate_connections >/dev/null 2>&1 || . /lib/nm-lib.sh
|
||||
type nm_generate_connections > /dev/null 2>&1 || . /lib/nm-lib.sh
|
||||
|
||||
if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then
|
||||
echo rd.neednet >> /etc/cmdline.d/35-neednet.conf
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
type getcmdline >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getcmdline > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
nm_generate_connections()
|
||||
{
|
||||
nm_generate_connections() {
|
||||
rm -f /run/NetworkManager/system-connections/*
|
||||
/usr/libexec/nm-initrd-generator -- $(getcmdline)
|
||||
|
||||
if getargbool 0 rd.neednet; then
|
||||
for i in /usr/lib/NetworkManager/system-connections/* \
|
||||
/run/NetworkManager/system-connections/* \
|
||||
/etc/NetworkManager/system-connections/* \
|
||||
/etc/sysconfig/network-scripts/ifcfg-*; do
|
||||
/run/NetworkManager/system-connections/* \
|
||||
/etc/NetworkManager/system-connections/* \
|
||||
/etc/sysconfig/network-scripts/ifcfg-*; do
|
||||
[ -f "$i" ] || continue
|
||||
echo '[ -f /tmp/nm.done ]' >$hookdir/initqueue/finished/nm.sh
|
||||
echo '[ -f /tmp/nm.done ]' > $hookdir/initqueue/finished/nm.sh
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
#!/bin/sh
|
||||
|
||||
type source_hook >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type source_hook > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
if [ -e /tmp/nm.done ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
[ -z "$DRACUT_SYSTEMD" ] && \
|
||||
for i in /usr/lib/NetworkManager/system-connections/* \
|
||||
/run/NetworkManager/system-connections/* \
|
||||
/etc/NetworkManager/system-connections/* \
|
||||
/etc/sysconfig/network-scripts/ifcfg-*; do
|
||||
[ -f "$i" ] || continue
|
||||
/usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
|
||||
break
|
||||
done
|
||||
[ -z "$DRACUT_SYSTEMD" ] \
|
||||
&& for i in /usr/lib/NetworkManager/system-connections/* \
|
||||
/run/NetworkManager/system-connections/* \
|
||||
/etc/NetworkManager/system-connections/* \
|
||||
/etc/sysconfig/network-scripts/ifcfg-*; do
|
||||
[ -f "$i" ] || continue
|
||||
/usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
|
||||
break
|
||||
done
|
||||
|
||||
if [ -s /run/NetworkManager/initrd/hostname ]; then
|
||||
cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname
|
||||
fi
|
||||
|
||||
for _i in /sys/class/net/*
|
||||
do
|
||||
for _i in /sys/class/net/*; do
|
||||
state=/run/NetworkManager/devices/$(cat $_i/ifindex)
|
||||
grep -q connection-uuid= $state 2>/dev/null || continue
|
||||
grep -q connection-uuid= $state 2> /dev/null || continue
|
||||
ifname=${_i##*/}
|
||||
sed -n 's/root-path/new_root_path/p;s/next-server/new_next_server/p' <$state >/tmp/dhclient.$ifname.dhcpopts
|
||||
sed -n 's/root-path/new_root_path/p;s/next-server/new_next_server/p' < $state > /tmp/dhclient.$ifname.dhcpopts
|
||||
source_hook initqueue/online $ifname
|
||||
/sbin/netroot $ifname
|
||||
done
|
||||
|
|
|
@ -61,6 +61,6 @@ install() {
|
|||
'/^\[Unit\]/aDefaultDependencies=no\
|
||||
Conflicts=shutdown.target\
|
||||
Before=shutdown.target' \
|
||||
"$initdir"$unit
|
||||
"$initdir"$unit
|
||||
done
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
# if there are no ifname parameters, just use NAME=KERNEL
|
||||
if ! getarg ifname= >/dev/null ; then
|
||||
if ! getarg ifname= > /dev/null; then
|
||||
return
|
||||
fi
|
||||
|
||||
command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
|
||||
command -v parse_ifname_opts > /dev/null || . /lib/net-lib.sh
|
||||
|
||||
{
|
||||
for p in $(getargs ifname=); do
|
||||
|
|
|
@ -9,22 +9,22 @@ check() {
|
|||
depends() {
|
||||
is_qemu_virtualized && echo -n "qemu-net "
|
||||
|
||||
for module in network-wicked network-manager network-legacy ; do
|
||||
if dracut_module_included "$module" ; then
|
||||
network_handler="$module"
|
||||
break
|
||||
fi
|
||||
done;
|
||||
|
||||
if [ -z "$network_handler" ]; then
|
||||
if find_binary wicked &>/dev/null ; then
|
||||
network_handler="network-wicked"
|
||||
elif [[ -x $dracutsysrootdir/usr/libexec/nm-initrd-generator ]]; then
|
||||
network_handler="network-manager"
|
||||
else
|
||||
network_handler="network-legacy"
|
||||
fi
|
||||
for module in network-wicked network-manager network-legacy; do
|
||||
if dracut_module_included "$module"; then
|
||||
network_handler="$module"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$network_handler" ]; then
|
||||
if find_binary wicked &> /dev/null; then
|
||||
network_handler="network-wicked"
|
||||
elif [[ -x $dracutsysrootdir/usr/libexec/nm-initrd-generator ]]; then
|
||||
network_handler="network-manager"
|
||||
else
|
||||
network_handler="network-legacy"
|
||||
fi
|
||||
fi
|
||||
echo "kernel-network-modules $network_handler"
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ is_ip() {
|
|||
echo "$1" | {
|
||||
IFS=. read a b c d
|
||||
test "$a" -ge 0 -a "$a" -le 255 \
|
||||
-a "$b" -ge 0 -a "$b" -le 255 \
|
||||
-a "$c" -ge 0 -a "$c" -le 255 \
|
||||
-a "$d" -ge 0 -a "$d" -le 255 \
|
||||
2> /dev/null
|
||||
-a "$b" -ge 0 -a "$b" -le 255 \
|
||||
-a "$c" -ge 0 -a "$c" -le 255 \
|
||||
-a "$d" -ge 0 -a "$d" -le 255 \
|
||||
2> /dev/null
|
||||
} && return 0
|
||||
return 1
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ get_ip() {
|
|||
}
|
||||
|
||||
iface_for_remote_addr() {
|
||||
set -- $(ip route get to $1 | sed 's/.*\bdev\b//p;q')
|
||||
set -- $(ip route get to $1 | sed 's/.*\bdev\b//p;q')
|
||||
echo $1
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ iface_for_mac() {
|
|||
# get the iface name for the given identifier - either a MAC, IP, or iface name
|
||||
iface_name() {
|
||||
case $1 in
|
||||
??:??:??:??:??:??|??-??-??-??-??-??) iface_for_mac $1 ;;
|
||||
*:*:*|*.*.*.*) iface_for_ip $1 ;;
|
||||
??:??:??:??:??:?? | ??-??-??-??-??-??) iface_for_mac $1 ;;
|
||||
*:*:* | *.*.*.*) iface_for_ip $1 ;;
|
||||
*) echo $1 ;;
|
||||
esac
|
||||
}
|
||||
|
@ -87,13 +87,16 @@ get_netroot_ip() {
|
|||
local prefix="" server="" rest=""
|
||||
splitsep "$1" ":" prefix server rest
|
||||
case $server in
|
||||
[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) echo "$server"; return 0 ;;
|
||||
[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)
|
||||
echo "$server"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
ip_is_local() {
|
||||
strstr "$(ip route get $1 2>/dev/null)" " via "
|
||||
strstr "$(ip route get $1 2> /dev/null)" " via "
|
||||
}
|
||||
|
||||
ifdown() {
|
||||
|
@ -103,9 +106,9 @@ ifdown() {
|
|||
ip addr flush dev $netif
|
||||
echo "#empty" > /etc/resolv.conf
|
||||
rm -f -- /tmp/net.$netif.did-setup
|
||||
[ -z "$DO_VLAN" ] && \
|
||||
[ -e /sys/class/net/$netif/address ] && \
|
||||
rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
|
||||
[ -z "$DO_VLAN" ] \
|
||||
&& [ -e /sys/class/net/$netif/address ] \
|
||||
&& rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
|
||||
# TODO: send "offline" uevent?
|
||||
}
|
||||
|
||||
|
@ -113,19 +116,19 @@ setup_net() {
|
|||
local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
|
||||
local _p
|
||||
[ -e /tmp/net.$netif.did-setup ] && return
|
||||
[ -z "$DO_VLAN" ] && \
|
||||
[ -e /sys/class/net/$netif/address ] && \
|
||||
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
|
||||
[ -z "$DO_VLAN" ] \
|
||||
&& [ -e /sys/class/net/$netif/address ] \
|
||||
&& [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
|
||||
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
|
||||
[ -z "$IFACES" ] && IFACES="$netif"
|
||||
# run the scripts written by ifup
|
||||
[ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
|
||||
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
|
||||
[ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
|
||||
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
|
||||
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
|
||||
# set up resolv.conf
|
||||
[ -e /tmp/net.$netif.resolv.conf ] && \
|
||||
awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
|
||||
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
|
||||
[ -e /tmp/net.$netif.resolv.conf ] \
|
||||
&& awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
|
||||
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
|
||||
|
||||
# add static route
|
||||
for _p in $(getargs rd.route); do
|
||||
|
@ -146,7 +149,7 @@ setup_net() {
|
|||
# RTNETLINK answers: Network is unreachable
|
||||
# Replace the default route again after static routes to cover
|
||||
# this scenario.
|
||||
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
|
||||
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
|
||||
|
||||
# Handle STP Timeout: arping the default gateway.
|
||||
# (or the root server, if a) it's local or b) there's no gateway.)
|
||||
|
@ -173,7 +176,7 @@ setup_net() {
|
|||
fi
|
||||
|
||||
if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! strstr "$dest" ":"; then
|
||||
if command -v arping2 >/dev/null; then
|
||||
if command -v arping2 > /dev/null; then
|
||||
arping2 -q -C 1 -c 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed"
|
||||
else
|
||||
arping -q -f -w 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed"
|
||||
|
@ -182,9 +185,9 @@ setup_net() {
|
|||
unset layer2
|
||||
|
||||
> /tmp/net.$netif.did-setup
|
||||
[ -z "$DO_VLAN" ] && \
|
||||
[ -e /sys/class/net/$netif/address ] && \
|
||||
> /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
|
||||
[ -z "$DO_VLAN" ] \
|
||||
&& [ -e /sys/class/net/$netif/address ] \
|
||||
&& > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
|
||||
}
|
||||
|
||||
save_netinfo() {
|
||||
|
@ -211,7 +214,7 @@ set_ifname() {
|
|||
done
|
||||
# otherwise, pick a new name and use that
|
||||
while :; do
|
||||
num=$(($num+1));
|
||||
num=$(($num + 1))
|
||||
[ -e /sys/class/net/$name$num ] && continue
|
||||
for n in $(getargs ifname=); do
|
||||
[ "$name$num" = "${n%%:*}" ] && continue 2
|
||||
|
@ -244,24 +247,39 @@ ibft_to_cmdline() {
|
|||
local dns1 dns2
|
||||
|
||||
[ -e ${iface}/mac ] || continue
|
||||
mac=$(read a < ${iface}/mac; echo $a)
|
||||
mac=$(
|
||||
read a < ${iface}/mac
|
||||
echo $a
|
||||
)
|
||||
[ -z "$mac" ] && continue
|
||||
dev=$(set_ifname ibft $mac)
|
||||
|
||||
[ -e /tmp/net.${dev}.has_ibft_config ] && continue
|
||||
|
||||
[ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a)
|
||||
[ -e ${iface}/flags ] && flags=$(
|
||||
read a < ${iface}/flags
|
||||
echo $a
|
||||
)
|
||||
# Skip invalid interfaces
|
||||
(( $flags & 1 )) || continue
|
||||
(($flags & 1)) || continue
|
||||
# Skip interfaces not used for booting unless using multipath
|
||||
if ! getargbool 0 rd.iscsi.mp ; then
|
||||
(( $flags & 2 )) || continue
|
||||
if ! getargbool 0 rd.iscsi.mp; then
|
||||
(($flags & 2)) || continue
|
||||
fi
|
||||
[ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a)
|
||||
[ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a)
|
||||
[ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
|
||||
[ -e ${iface}/dhcp ] && dhcp=$(
|
||||
read a < ${iface}/dhcp
|
||||
echo $a
|
||||
)
|
||||
[ -e ${iface}/origin ] && origin=$(
|
||||
read a < ${iface}/origin
|
||||
echo $a
|
||||
)
|
||||
[ -e ${iface}/ip-addr ] && ip=$(
|
||||
read a < ${iface}/ip-addr
|
||||
echo $a
|
||||
)
|
||||
|
||||
if [ -n "$ip" ] ; then
|
||||
if [ -n "$ip" ]; then
|
||||
case "$ip" in
|
||||
*.*.*.*)
|
||||
family=ipv4
|
||||
|
@ -272,7 +290,7 @@ ibft_to_cmdline() {
|
|||
esac
|
||||
fi
|
||||
if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then
|
||||
if [ "$family" = "ipv6" ] ; then
|
||||
if [ "$family" = "ipv6" ]; then
|
||||
echo "ip=$dev:dhcp6"
|
||||
else
|
||||
echo "ip=$dev:dhcp"
|
||||
|
@ -280,23 +298,41 @@ ibft_to_cmdline() {
|
|||
elif [ -e ${iface}/ip-addr ]; then
|
||||
# skip not assigned ip adresses
|
||||
[ "$ip" = "0.0.0.0" ] && continue
|
||||
[ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a)
|
||||
[ -e ${iface}/gateway ] && gw=$(
|
||||
read a < ${iface}/gateway
|
||||
echo $a
|
||||
)
|
||||
[ "$gateway" = "0.0.0.0" ] && unset $gateway
|
||||
[ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a)
|
||||
[ -e ${iface}/prefix-len ] && prefix=$(read a < ${iface}/prefix-len; echo $a)
|
||||
[ -e ${iface}/primary-dns ] && dns1=$(read a < ${iface}/primary-dns; echo $a)
|
||||
[ -e ${iface}/subnet-mask ] && mask=$(
|
||||
read a < ${iface}/subnet-mask
|
||||
echo $a
|
||||
)
|
||||
[ -e ${iface}/prefix-len ] && prefix=$(
|
||||
read a < ${iface}/prefix-len
|
||||
echo $a
|
||||
)
|
||||
[ -e ${iface}/primary-dns ] && dns1=$(
|
||||
read a < ${iface}/primary-dns
|
||||
echo $a
|
||||
)
|
||||
[ "$dns1" = "0.0.0.0" ] && unset $dns1
|
||||
[ -e ${iface}/secondary-dns ] && dns2=$(read a < ${iface}/secondary-dns; echo $a)
|
||||
[ -e ${iface}/secondary-dns ] && dns2=$(
|
||||
read a < ${iface}/secondary-dns
|
||||
echo $a
|
||||
)
|
||||
[ "$dns2" = "0.0.0.0" ] && unset $dns2
|
||||
[ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a)
|
||||
if [ "$family" = "ipv6" ] ; then
|
||||
if [ -n "$ip" ] ; then
|
||||
[ -e ${iface}/hostname ] && hostname=$(
|
||||
read a < ${iface}/hostname
|
||||
echo $a
|
||||
)
|
||||
if [ "$family" = "ipv6" ]; then
|
||||
if [ -n "$ip" ]; then
|
||||
ip="[$ip]"
|
||||
[ -n "$prefix" ] || prefix=64
|
||||
ip="[${ip}/${prefix}]"
|
||||
mask=
|
||||
fi
|
||||
if [ -n "$gw" ] ; then
|
||||
if [ -n "$gw" ]; then
|
||||
gw="[${gw}]"
|
||||
fi
|
||||
fi
|
||||
|
@ -315,7 +351,10 @@ ibft_to_cmdline() {
|
|||
fi
|
||||
|
||||
if [ -e ${iface}/vlan ]; then
|
||||
vlan=$(read a < ${iface}/vlan; echo $a)
|
||||
vlan=$(
|
||||
read a < ${iface}/vlan
|
||||
echo $a
|
||||
)
|
||||
if [ "$vlan" -ne "0" ]; then
|
||||
case "$vlan" in
|
||||
[0-9]*)
|
||||
|
@ -338,8 +377,7 @@ ibft_to_cmdline() {
|
|||
) >> /etc/cmdline.d/40-ibft.conf
|
||||
}
|
||||
|
||||
parse_iscsi_root()
|
||||
{
|
||||
parse_iscsi_root() {
|
||||
local v
|
||||
v=${1#iscsi:}
|
||||
|
||||
|
@ -406,17 +444,22 @@ parse_iscsi_root()
|
|||
set $v
|
||||
IFS="$OLDIFS"
|
||||
|
||||
iscsi_protocol=$1; shift # ignored
|
||||
iscsi_target_port=$1; shift
|
||||
iscsi_protocol=$1
|
||||
shift # ignored
|
||||
iscsi_target_port=$1
|
||||
shift
|
||||
|
||||
if [ -n "$iscsi_target_name" ]; then
|
||||
if [ $# -eq 3 ]; then
|
||||
iscsi_iface_name=$1; shift
|
||||
iscsi_iface_name=$1
|
||||
shift
|
||||
fi
|
||||
if [ $# -eq 2 ]; then
|
||||
iscsi_netdev_name=$1; shift
|
||||
iscsi_netdev_name=$1
|
||||
shift
|
||||
fi
|
||||
iscsi_lun=$1; shift
|
||||
iscsi_lun=$1
|
||||
shift
|
||||
if [ $# -ne 0 ]; then
|
||||
warn "Invalid parameter in iscsi: parameter!"
|
||||
return 1
|
||||
|
@ -424,15 +467,17 @@ parse_iscsi_root()
|
|||
return 0
|
||||
fi
|
||||
|
||||
|
||||
if [ $# -gt 3 ] && [ -n "$1$2" ]; then
|
||||
if [ -z "$3" ] || [ "$3" -ge 0 ] 2>/dev/null ; then
|
||||
iscsi_iface_name=$1; shift
|
||||
iscsi_netdev_name=$1; shift
|
||||
if [ -z "$3" ] || [ "$3" -ge 0 ] 2> /dev/null; then
|
||||
iscsi_iface_name=$1
|
||||
shift
|
||||
iscsi_netdev_name=$1
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
|
||||
iscsi_lun=$1; shift
|
||||
iscsi_lun=$1
|
||||
shift
|
||||
|
||||
iscsi_target_name=$(printf "%s:" "$@")
|
||||
iscsi_target_name=${iscsi_target_name%:}
|
||||
|
@ -482,7 +527,7 @@ ip_to_var() {
|
|||
|
||||
# handle special values for ksdevice
|
||||
case "$dev" in
|
||||
bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
|
||||
bootif | BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
|
||||
link) dev="" ;; # FIXME: do something useful with this
|
||||
ibft) dev="" ;; # ignore - ibft is handled elsewhere
|
||||
esac
|
||||
|
@ -513,7 +558,7 @@ ip_to_var() {
|
|||
[ -n "$6" ] && dev=$6
|
||||
[ -n "$7" ] && autoconf=$7
|
||||
case "$8" in
|
||||
[0-9a-fA-F]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*)
|
||||
[0-9a-fA-F]*:* | [0-9]*.[0-9]*.[0-9]*.[0-9]*)
|
||||
dns1="$8"
|
||||
[ -n "$9" ] && dns2="$9"
|
||||
;;
|
||||
|
@ -531,7 +576,7 @@ ip_to_var() {
|
|||
elif [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
|
||||
macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
|
||||
fi
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
@ -555,11 +600,18 @@ route_to_var() {
|
|||
|
||||
unset route_mask route_gw route_dev
|
||||
case $# in
|
||||
2) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2"
|
||||
return 0;;
|
||||
3) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2"; [ -n "$3" ] && route_dev="$3"
|
||||
return 0;;
|
||||
*) return 1;;
|
||||
2)
|
||||
[ -n "$1" ] && route_mask="$1"
|
||||
[ -n "$2" ] && route_gw="$2"
|
||||
return 0
|
||||
;;
|
||||
3)
|
||||
[ -n "$1" ] && route_mask="$1"
|
||||
[ -n "$2" ] && route_gw="$2"
|
||||
[ -n "$3" ] && route_dev="$3"
|
||||
return 0
|
||||
;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -584,7 +636,7 @@ parse_ifname_opts() {
|
|||
esac
|
||||
|
||||
case $ifname_if in
|
||||
eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]|eth[0-9][0-9][0-9][0-9])
|
||||
eth[0-9] | eth[0-9][0-9] | eth[0-9][0-9][0-9] | eth[0-9][0-9][0-9][0-9])
|
||||
warn "ifname=$ifname_if uses the kernel name space for interfaces"
|
||||
warn "This can fail for multiple network interfaces and is discouraged!"
|
||||
warn "Please use a custom name like \"netboot\" or \"bluesocket\""
|
||||
|
@ -600,13 +652,13 @@ wait_for_if_link() {
|
|||
local li
|
||||
local timeout="$(getargs rd.net.timeout.iflink=)"
|
||||
timeout=${timeout:-60}
|
||||
timeout=$(($timeout*10))
|
||||
timeout=$(($timeout * 10))
|
||||
|
||||
while [ $cnt -lt $timeout ]; do
|
||||
li=$(ip link show dev $1 2>/dev/null)
|
||||
li=$(ip link show dev $1 2> /dev/null)
|
||||
[ -n "$li" ] && return 0
|
||||
sleep 0.1
|
||||
cnt=$(($cnt+1))
|
||||
cnt=$(($cnt + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
@ -616,27 +668,30 @@ wait_for_if_up() {
|
|||
local li
|
||||
local timeout="$(getargs rd.net.timeout.ifup=)"
|
||||
timeout=${timeout:-20}
|
||||
timeout=$(($timeout*10))
|
||||
timeout=$(($timeout * 10))
|
||||
|
||||
while [ $cnt -lt $timeout ]; do
|
||||
li=$(ip link show up dev $1)
|
||||
if [ -n "$li" ]; then
|
||||
case "$li" in
|
||||
*\<UP*)
|
||||
return 0;;
|
||||
return 0
|
||||
;;
|
||||
*\<*,UP\>*)
|
||||
return 0;;
|
||||
return 0
|
||||
;;
|
||||
*\<*,UP,*\>*)
|
||||
return 0;;
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if strstr "$li" "LOWER_UP" \
|
||||
&& strstr "$li" "state UNKNOWN" \
|
||||
&& ! strstr "$li" "DORMANT"; then
|
||||
&& strstr "$li" "state UNKNOWN" \
|
||||
&& ! strstr "$li" "DORMANT"; then
|
||||
return 0
|
||||
fi
|
||||
sleep 0.1
|
||||
cnt=$(($cnt+1))
|
||||
cnt=$(($cnt + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
@ -645,13 +700,13 @@ wait_for_route_ok() {
|
|||
local cnt=0
|
||||
local timeout="$(getargs rd.net.timeout.route=)"
|
||||
timeout=${timeout:-20}
|
||||
timeout=$(($timeout*10))
|
||||
timeout=$(($timeout * 10))
|
||||
|
||||
while [ $cnt -lt $timeout ]; do
|
||||
li=$(ip route show)
|
||||
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
|
||||
sleep 0.1
|
||||
cnt=$(($cnt+1))
|
||||
cnt=$(($cnt + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
@ -660,7 +715,7 @@ wait_for_ipv6_dad_link() {
|
|||
local cnt=0
|
||||
local timeout="$(getargs rd.net.timeout.ipv6dad=)"
|
||||
timeout=${timeout:-50}
|
||||
timeout=$(($timeout*10))
|
||||
timeout=$(($timeout * 10))
|
||||
|
||||
while [ $cnt -lt $timeout ]; do
|
||||
[ -n "$(ip -6 addr show dev "$1" scope link)" ] \
|
||||
|
@ -669,7 +724,7 @@ wait_for_ipv6_dad_link() {
|
|||
[ -n "$(ip -6 addr show dev "$1" scope link dadfailed)" ] \
|
||||
&& return 1
|
||||
sleep 0.1
|
||||
cnt=$(($cnt+1))
|
||||
cnt=$(($cnt + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
@ -678,7 +733,7 @@ wait_for_ipv6_dad() {
|
|||
local cnt=0
|
||||
local timeout="$(getargs rd.net.timeout.ipv6dad=)"
|
||||
timeout=${timeout:-50}
|
||||
timeout=$(($timeout*10))
|
||||
timeout=$(($timeout * 10))
|
||||
|
||||
while [ $cnt -lt $timeout ]; do
|
||||
[ -n "$(ip -6 addr show dev "$1")" ] \
|
||||
|
@ -688,7 +743,7 @@ wait_for_ipv6_dad() {
|
|||
[ -n "$(ip -6 addr show dev "$1" dadfailed)" ] \
|
||||
&& return 1
|
||||
sleep 0.1
|
||||
cnt=$(($cnt+1))
|
||||
cnt=$(($cnt + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
@ -697,28 +752,26 @@ wait_for_ipv6_auto() {
|
|||
local cnt=0
|
||||
local timeout="$(getargs rd.net.timeout.ipv6auto=)"
|
||||
timeout=${timeout:-40}
|
||||
timeout=$(($timeout*10))
|
||||
timeout=$(($timeout * 10))
|
||||
|
||||
while [ $cnt -lt $timeout ]; do
|
||||
[ -z "$(ip -6 addr show dev "$1" tentative)" ] \
|
||||
&& [ -n "$(ip -6 route list proto ra dev "$1" | grep ^default)" ] \
|
||||
&& return 0
|
||||
sleep 0.1
|
||||
cnt=$(($cnt+1))
|
||||
cnt=$(($cnt + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
linkup() {
|
||||
wait_for_if_link $1 2>/dev/null\
|
||||
&& ip link set $1 up 2>/dev/null\
|
||||
&& wait_for_if_up $1 2>/dev/null
|
||||
wait_for_if_link $1 2> /dev/null && ip link set $1 up 2> /dev/null && wait_for_if_up $1 2> /dev/null
|
||||
}
|
||||
|
||||
type hostname >/dev/null 2>&1 || \
|
||||
hostname() {
|
||||
cat /proc/sys/kernel/hostname
|
||||
}
|
||||
type hostname > /dev/null 2>&1 \
|
||||
|| hostname() {
|
||||
cat /proc/sys/kernel/hostname
|
||||
}
|
||||
|
||||
iface_has_carrier() {
|
||||
local cnt=0
|
||||
|
@ -728,7 +781,7 @@ iface_has_carrier() {
|
|||
[ -d "$interface" ] || return 2
|
||||
local timeout="$(getargs rd.net.timeout.carrier=)"
|
||||
timeout=${timeout:-10}
|
||||
timeout=$(($timeout*10))
|
||||
timeout=$(($timeout * 10))
|
||||
|
||||
linkup "$1"
|
||||
|
||||
|
@ -747,7 +800,7 @@ iface_has_carrier() {
|
|||
# double check the syscfs carrier flag
|
||||
[ -e "$interface/carrier" ] && [ "$(cat $interface/carrier)" = 1 ] && return 0
|
||||
sleep 0.1
|
||||
cnt=$(($cnt+1))
|
||||
cnt=$(($cnt + 1))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
@ -791,21 +844,22 @@ is_persistent_ethernet_name() {
|
|||
|
||||
case "$_netif" in
|
||||
# udev persistent interface names
|
||||
eno[0-9]|eno[0-9][0-9]|eno[0-9][0-9][0-9]*)
|
||||
;;
|
||||
ens[0-9]|ens[0-9][0-9]|ens[0-9][0-9][0-9]*)
|
||||
;;
|
||||
enp[0-9]s[0-9]*|enp[0-9][0-9]s[0-9]*|enp[0-9][0-9][0-9]*s[0-9]*)
|
||||
;;
|
||||
enP*p[0-9]s[0-9]*|enP*p[0-9][0-9]s[0-9]*|enP*p[0-9][0-9][0-9]*s[0-9]*)
|
||||
;;
|
||||
# biosdevname
|
||||
em[0-9]|em[0-9][0-9]|em[0-9][0-9][0-9]*)
|
||||
;;
|
||||
p[0-9]p[0-9]*|p[0-9][0-9]p[0-9]*|p[0-9][0-9][0-9]*p[0-9]*)
|
||||
;;
|
||||
eno[0-9] | eno[0-9][0-9] | eno[0-9][0-9][0-9]*) ;;
|
||||
|
||||
ens[0-9] | ens[0-9][0-9] | ens[0-9][0-9][0-9]*) ;;
|
||||
|
||||
enp[0-9]s[0-9]* | enp[0-9][0-9]s[0-9]* | enp[0-9][0-9][0-9]*s[0-9]*) ;;
|
||||
|
||||
enP*p[0-9]s[0-9]* | enP*p[0-9][0-9]s[0-9]* | enP*p[0-9][0-9][0-9]*s[0-9]*) ;;
|
||||
|
||||
# biosdevname
|
||||
em[0-9] | em[0-9][0-9] | em[0-9][0-9][0-9]*) ;;
|
||||
|
||||
p[0-9]p[0-9]* | p[0-9][0-9]p[0-9]* | p[0-9][0-9][0-9]*p[0-9]*) ;;
|
||||
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
@ -818,13 +872,13 @@ is_kernel_ethernet_name() {
|
|||
_name_assign_type=$(cat "/sys/class/net/$_netif/name_assign_type")
|
||||
|
||||
case "$_name_assign_type" in
|
||||
2|3|4)
|
||||
2 | 3 | 4)
|
||||
# NET_NAME_PREDICTABLE 2
|
||||
# NET_NAME_USER 3
|
||||
# NET_NAME_RENAMED 4
|
||||
return 1
|
||||
;;
|
||||
1|*)
|
||||
1 | *)
|
||||
# NET_NAME_ENUM 1
|
||||
return 0
|
||||
;;
|
||||
|
@ -833,11 +887,12 @@ is_kernel_ethernet_name() {
|
|||
|
||||
# fallback to error prone manual name check
|
||||
case "$_netif" in
|
||||
eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]*)
|
||||
eth[0-9] | eth[0-9][0-9] | eth[0-9][0-9][0-9]*)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
@ -849,12 +904,12 @@ iface_get_subchannels() {
|
|||
_netif="$1"
|
||||
|
||||
_subchannels=$({
|
||||
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
|
||||
[ -e $i ] || continue
|
||||
channel=$(readlink -f $i)
|
||||
printf -- "%s" "${channel##*/},"
|
||||
done
|
||||
})
|
||||
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
|
||||
[ -e $i ] || continue
|
||||
channel=$(readlink -f $i)
|
||||
printf -- "%s" "${channel##*/},"
|
||||
done
|
||||
})
|
||||
[ -n "$_subchannels" ] || return 1
|
||||
|
||||
printf -- "%s" ${_subchannels%,}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v setup_net >/dev/null || . /lib/net-lib.sh
|
||||
command -v getarg > /dev/null || . /lib/dracut-lib.sh
|
||||
command -v setup_net > /dev/null || . /lib/net-lib.sh
|
||||
|
||||
# Huh? Empty $1?
|
||||
[ -z "$1" ] && exit 1
|
||||
|
@ -24,7 +24,7 @@ netif=$1
|
|||
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
|
||||
|
||||
case "$netif" in
|
||||
??:??:??:??:??:??) # MAC address
|
||||
??:??:??:??:??:??) # MAC address
|
||||
for i in /sys/class/net/*/address; do
|
||||
mac=$(cat $i)
|
||||
if [ "$mac" = "$netif" ]; then
|
||||
|
@ -32,7 +32,7 @@ case "$netif" in
|
|||
netif=${i##*/}
|
||||
break
|
||||
fi
|
||||
done
|
||||
done ;;
|
||||
esac
|
||||
|
||||
# Figure out the handler for root=dhcp by recalling all netroot cmdline
|
||||
|
@ -44,7 +44,7 @@ if [ -z "$2" ]; then
|
|||
|
||||
# If we have a specific bootdev with no dhcpoptions or empty root-path,
|
||||
# we die. Otherwise we just warn
|
||||
if [ -z "$new_root_path" ] ; then
|
||||
if [ -z "$new_root_path" ]; then
|
||||
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
|
||||
warn "No dhcp root-path received for '$netif' trying other interfaces if available"
|
||||
exit 1
|
||||
|
@ -58,7 +58,7 @@ if [ -z "$2" ]; then
|
|||
# FIXME!
|
||||
unset rootok
|
||||
for f in $hookdir/cmdline/90*.sh; do
|
||||
[ -f "$f" ] && . "$f";
|
||||
[ -f "$f" ] && . "$f"
|
||||
done
|
||||
else
|
||||
rootok="1"
|
||||
|
@ -74,7 +74,7 @@ if [ -z "$2" ]; then
|
|||
handler=${netroot%%:*}
|
||||
handler=${handler%%4}
|
||||
handler=$(command -v ${handler}root)
|
||||
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
|
||||
if [ -z "$netroot" ] || [ ! -e "$handler" ]; then
|
||||
die "No handler for netroot type '$netroot'"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -17,4 +17,3 @@ install() {
|
|||
inst_binary awk
|
||||
inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
# NFS root might have reached here before /tmp/net.ifaces was written
|
||||
type is_persistent_ethernet_name >/dev/null 2>&1 || . /lib/net-lib.sh
|
||||
type is_persistent_ethernet_name > /dev/null 2>&1 || . /lib/net-lib.sh
|
||||
|
||||
udevadm settle --timeout=30
|
||||
|
||||
mkdir -m 0755 -p /tmp/ifcfg/
|
||||
mkdir -m 0755 -p /tmp/ifcfg-leases/
|
||||
|
||||
get_config_line_by_subchannel()
|
||||
{
|
||||
get_config_line_by_subchannel() {
|
||||
local CHANNEL
|
||||
local line
|
||||
|
||||
|
@ -62,7 +61,7 @@ print_s390() {
|
|||
shift
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
*=*) OPTIONS="$OPTIONS $1";;
|
||||
*=*) OPTIONS="$OPTIONS $1" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@ -109,7 +108,7 @@ interface_bind() {
|
|||
echo "DEVICE=\"$_netif\""
|
||||
}
|
||||
|
||||
for netup in /tmp/net.*.did-setup ; do
|
||||
for netup in /tmp/net.*.did-setup; do
|
||||
[ -f $netup ] || continue
|
||||
|
||||
netif=${netup%%.did-setup}
|
||||
|
@ -211,7 +210,7 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
|
||||
fi
|
||||
|
||||
if [ -n "$vlan" ] ; then
|
||||
if [ -n "$vlan" ]; then
|
||||
{
|
||||
echo "TYPE=Vlan"
|
||||
echo "DEVICE=\"$netif\""
|
||||
|
@ -220,7 +219,7 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
} >> /tmp/ifcfg/ifcfg-$netif
|
||||
fi
|
||||
|
||||
if [ -n "$bond" ] ; then
|
||||
if [ -n "$bond" ]; then
|
||||
# bond interface
|
||||
{
|
||||
# This variable is an indicator of a bond interface for initscripts
|
||||
|
@ -229,7 +228,7 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
echo "TYPE=Bond"
|
||||
} >> /tmp/ifcfg/ifcfg-$netif
|
||||
|
||||
for slave in $bondslaves ; do
|
||||
for slave in $bondslaves; do
|
||||
# write separate ifcfg file for the raw eth interface
|
||||
(
|
||||
echo "# Generated by dracut initrd"
|
||||
|
@ -247,13 +246,13 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
done
|
||||
fi
|
||||
|
||||
if [ -n "$bridge" ] ; then
|
||||
if [ -n "$bridge" ]; then
|
||||
# bridge
|
||||
{
|
||||
echo "TYPE=Bridge"
|
||||
echo "NAME=\"$netif\""
|
||||
} >> /tmp/ifcfg/ifcfg-$netif
|
||||
for slave in $bridgeslaves ; do
|
||||
for slave in $bridgeslaves; do
|
||||
# write separate ifcfg file for the raw eth interface
|
||||
(
|
||||
echo "# Generated by dracut initrd"
|
||||
|
@ -272,7 +271,7 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
i=1
|
||||
for ns in $(getargs nameserver) $dns1 $dns2; do
|
||||
echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
|
||||
i=$((i+1))
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
[ -f /tmp/net.route6."$netif" ] && cp /tmp/net.route6."$netif" /tmp/ifcfg/route6-"$netif"
|
||||
|
@ -287,7 +286,7 @@ echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
|
|||
{
|
||||
cp /tmp/net.* /run/initramfs/
|
||||
for i in /tmp/net.*.resolv.conf; do
|
||||
[ -f "$i" ] && cat "$i"
|
||||
[ -f "$i" ] && cat "$i"
|
||||
done | awk '!($0 in a) { a[$0]; print }' > /run/initramfs/state/etc/resolv.conf
|
||||
[ -s /run/initramfs/state/etc/resolv.conf ] || rm -f /run/initramfs/state/etc/resolv.conf
|
||||
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
|
||||
|
|
|
@ -28,9 +28,9 @@ install() {
|
|||
fi
|
||||
|
||||
for _dir in $libdirs; do
|
||||
[[ -d $dracutsysrootdir$_dir ]] || continue
|
||||
[[ -d $dracutsysrootdir$_dir ]] || continue
|
||||
for _lib in $dracutsysrootdir$_dir/libcurl.so.*; do
|
||||
[[ -e $_lib ]] || continue
|
||||
[[ -e $_lib ]] || continue
|
||||
[[ $_nssckbi ]] || _nssckbi=$(grep -F --binary-files=text -z libnssckbi $_lib)
|
||||
_crt=$(grep -F --binary-files=text -z .crt $_lib)
|
||||
[[ $_crt ]] || continue
|
||||
|
@ -47,15 +47,15 @@ install() {
|
|||
# If its truly NSS libnssckbi, it includes its own trust bundle,
|
||||
# but if it's really p11-kit-trust.so, we need to find the dirs
|
||||
# where it will look for a trust bundle and install them too.
|
||||
if ! [[ $_found ]] && [[ $_nssckbi ]] ; then
|
||||
if ! [[ $_found ]] && [[ $_nssckbi ]]; then
|
||||
_found=1
|
||||
inst_libdir_file "libnssckbi.so*" || _found=
|
||||
for _dir in $libdirs; do
|
||||
[[ -e $dracutsysrootdir$_dir/libnssckbi.so ]] || continue
|
||||
# this looks for directory-ish strings in the file
|
||||
for _p11roots in $(grep -o --binary-files=text "/[[:alpha:]][[:print:]]*" $dracutsysrootdir$_dir/libnssckbi.so) ; do
|
||||
for _p11roots in $(grep -o --binary-files=text "/[[:alpha:]][[:print:]]*" $dracutsysrootdir$_dir/libnssckbi.so); do
|
||||
# the string can be a :-separated list of dirs
|
||||
for _p11root in $(echo "$_p11roots" | tr ':' '\n') ; do
|
||||
for _p11root in $(echo "$_p11roots" | tr ':' '\n'); do
|
||||
# check if it's actually a directory (there are
|
||||
# several false positives in the results)
|
||||
[[ -d "$dracutsysrootdir$_p11root" ]] || continue
|
||||
|
@ -65,8 +65,8 @@ install() {
|
|||
[[ -d "$dracutsysrootdir${_p11root}/blacklist" ]] || continue
|
||||
# so now we know it's really a p11-kit trust dir;
|
||||
# install everything in it
|
||||
for _p11item in $(find "$dracutsysrootdir$_p11root") ; do
|
||||
if ! inst "${_p11item#$dracutsysrootdir}" ; then
|
||||
for _p11item in $(find "$dracutsysrootdir$_p11root"); do
|
||||
if ! inst "${_p11item#$dracutsysrootdir}"; then
|
||||
dwarn "Couldn't install '${_p11item#$dracutsysrootdir}' from p11-kit trust dir '${_p11root#$dracutsysrootdir}'; HTTPS might not work."
|
||||
continue
|
||||
fi
|
||||
|
@ -77,4 +77,3 @@ install() {
|
|||
fi
|
||||
[[ $_found ]] || dwarn "Couldn't find SSL CA cert bundle or libnssckbi.so; HTTPS won't work."
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Authors:
|
||||
# Will Woods <wwoods@redhat.com>
|
||||
|
||||
type mkuniqdir >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type mkuniqdir > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
# fetch_url URL [OUTFILE]
|
||||
# fetch the given URL to a locally-visible location.
|
||||
|
@ -39,7 +39,8 @@ get_url_handler() {
|
|||
# add_url_handler HANDLERNAME SCHEME [SCHEME...]
|
||||
# associate the named handler with the named scheme(s).
|
||||
add_url_handler() {
|
||||
local handler="$1"; shift
|
||||
local handler="$1"
|
||||
shift
|
||||
local schemes="$@" scheme=""
|
||||
set --
|
||||
for scheme in $schemes; do
|
||||
|
@ -67,14 +68,17 @@ curl_fetch_url() {
|
|||
curl $curl_args --output - -- "$url" > "$outloc" || return $?
|
||||
else
|
||||
local outdir="$(mkuniqdir /tmp curl_fetch_url)"
|
||||
( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
|
||||
(
|
||||
cd "$outdir"
|
||||
curl $curl_args --remote-name "$url" || return $?
|
||||
)
|
||||
outloc="$outdir/$(ls -A $outdir)"
|
||||
fi
|
||||
if ! [ -f "$outloc" ]; then
|
||||
warn "Downloading '$url' failed!"
|
||||
return 253
|
||||
warn "Downloading '$url' failed!"
|
||||
return 253
|
||||
fi
|
||||
if [ -z "$2" ]; then echo "$outloc" ; fi
|
||||
if [ -z "$2" ]; then echo "$outloc"; fi
|
||||
}
|
||||
add_url_handler curl_fetch_url http https ftp tftp
|
||||
|
||||
|
@ -95,7 +99,10 @@ ctorrent_fetch_url() {
|
|||
curl $curl_args --output - -- "$url" > "$torrent_outloc" || return $?
|
||||
else
|
||||
local outdir="$(mkuniqdir /tmp torrent_fetch_url)"
|
||||
( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
|
||||
(
|
||||
cd "$outdir"
|
||||
curl $curl_args --remote-name "$url" || return $?
|
||||
)
|
||||
torrent_outloc="$outdir/$(ls -A $outdir)"
|
||||
outloc=${torrent_outloc%.*}
|
||||
fi
|
||||
|
@ -108,10 +115,10 @@ ctorrent_fetch_url() {
|
|||
warn "Torrent download of '$url' failed!"
|
||||
return 253
|
||||
fi
|
||||
if [ -z "$2" ]; then echo "$outloc" ; fi
|
||||
if [ -z "$2" ]; then echo "$outloc"; fi
|
||||
}
|
||||
|
||||
command -v ctorrent >/dev/null \
|
||||
command -v ctorrent > /dev/null \
|
||||
&& add_url_handler ctorrent_fetch_url torrent
|
||||
|
||||
### NFS ##############################################################
|
||||
|
@ -152,6 +159,6 @@ nfs_fetch_url() {
|
|||
cp -f -- "$mntdir/$filename" "$outloc" || return $?
|
||||
fi
|
||||
[ -f "$outloc" ] || return 253
|
||||
if [ -z "$2" ]; then echo "$outloc" ; fi
|
||||
if [ -z "$2" ]; then echo "$outloc"; fi
|
||||
}
|
||||
command -v nfs_to_var >/dev/null && add_url_handler nfs_fetch_url nfs nfs4
|
||||
command -v nfs_to_var > /dev/null && add_url_handler nfs_fetch_url nfs nfs4
|
||||
|
|
|
@ -33,9 +33,9 @@ installkernel() {
|
|||
if [[ $hostonly ]]; then
|
||||
for i in /sys/bus/{pci/devices,platform/devices,virtio/devices,soc/devices/soc?}/*/modalias; do
|
||||
[[ -e $i ]] || continue
|
||||
[[ -n $(<"$i") ]] || continue
|
||||
if hostonly="" dracut_instmods --silent -s "drm_crtc_init|drm_dev_register|drm_encoder_init" -S "iw_handler_get_spy" $(<"$i"); then
|
||||
if strstr "$(modinfo -F filename $(<"$i") 2>/dev/null)" radeon.ko; then
|
||||
[[ -n $(< "$i") ]] || continue
|
||||
if hostonly="" dracut_instmods --silent -s "drm_crtc_init|drm_dev_register|drm_encoder_init" -S "iw_handler_get_spy" $(< "$i"); then
|
||||
if strstr "$(modinfo -F filename $(< "$i") 2> /dev/null)" radeon.ko; then
|
||||
hostonly='' instmods amdkfd
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -32,7 +32,7 @@ install() {
|
|||
dwarn "${line}"
|
||||
else
|
||||
derror "${line}"
|
||||
(( $_ret == 0 )) && _ret=1
|
||||
(($_ret == 0)) && _ret=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
@ -40,7 +40,7 @@ install() {
|
|||
return ${_ret}
|
||||
}
|
||||
|
||||
find_binary splash_geninitramfs >/dev/null || return 1
|
||||
find_binary splash_geninitramfs > /dev/null || return 1
|
||||
|
||||
_opts=''
|
||||
if [[ ${DRACUT_GENSPLASH_THEME} ]]; then
|
||||
|
@ -62,7 +62,7 @@ install() {
|
|||
|
||||
dinfo "Installing Gentoo Splash (using the ${_splash_theme} theme)"
|
||||
|
||||
pushd "${initdir}" >/dev/null
|
||||
pushd "${initdir}" > /dev/null
|
||||
mv dev dev.old
|
||||
call_splash_geninitramfs "${initdir}" ${_opts} ${_splash_theme} || {
|
||||
derror "Could not build splash"
|
||||
|
@ -70,7 +70,7 @@ install() {
|
|||
}
|
||||
rm -rf dev
|
||||
mv dev.old dev
|
||||
popd >/dev/null
|
||||
popd > /dev/null
|
||||
|
||||
inst_multiple chvt
|
||||
inst /usr/share/splashutils/initrd.splash /lib/gensplash-lib.sh
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
pkglib_dir() {
|
||||
local _dirs="/usr/lib/plymouth /usr/libexec/plymouth/"
|
||||
if find_binary dpkg-architecture &>/dev/null; then
|
||||
if find_binary dpkg-architecture &> /dev/null; then
|
||||
_dirs+=" /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/plymouth"
|
||||
fi
|
||||
for _dir in $_dirs; do
|
||||
|
@ -48,4 +48,3 @@ install() {
|
|||
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
plymouth --hide-splash 2>/dev/null || :
|
||||
plymouth --hide-splash 2> /dev/null || :
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
if type plymouth >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
|
||||
if type plymouth > /dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
|
||||
plymouth --newroot=$NEWROOT
|
||||
fi
|
||||
|
|
|
@ -15,10 +15,10 @@ inst_libdir_file "plymouth/text.so" "plymouth/details.so"
|
|||
if [[ $hostonly ]]; then
|
||||
inst_multiple \
|
||||
"/usr/share/plymouth/themes/details/details.plymouth" \
|
||||
"/usr/share/plymouth/themes/text/text.plymouth" \
|
||||
"/usr/share/plymouth/themes/text/text.plymouth"
|
||||
|
||||
if [[ -d $dracutsysrootdir/usr/share/plymouth/themes/${PLYMOUTH_THEME} ]]; then
|
||||
for x in "/usr/share/plymouth/themes/${PLYMOUTH_THEME}"/* ; do
|
||||
for x in "/usr/share/plymouth/themes/${PLYMOUTH_THEME}"/*; do
|
||||
[[ -f "$dracutsysrootdir$x" ]] || break
|
||||
inst $x
|
||||
done
|
||||
|
@ -27,18 +27,18 @@ if [[ $hostonly ]]; then
|
|||
if [[ -L $dracutsysrootdir/usr/share/plymouth/themes/default.plymouth ]]; then
|
||||
inst /usr/share/plymouth/themes/default.plymouth
|
||||
# Install plugin for this theme
|
||||
PLYMOUTH_PLUGIN=$(grep "^ModuleName=" "$dracutsysrootdir"/usr/share/plymouth/themes/default.plymouth | while read a b c || [ -n "$b" ]; do echo $b; done;)
|
||||
PLYMOUTH_PLUGIN=$(grep "^ModuleName=" "$dracutsysrootdir"/usr/share/plymouth/themes/default.plymouth | while read a b c || [ -n "$b" ]; do echo $b; done)
|
||||
inst_libdir_file "plymouth/${PLYMOUTH_PLUGIN}.so"
|
||||
fi
|
||||
else
|
||||
for x in "$dracutsysrootdir"/usr/share/plymouth/themes/{text,details}/* ; do
|
||||
for x in "$dracutsysrootdir"/usr/share/plymouth/themes/{text,details}/*; do
|
||||
[[ -f "$x" ]] || continue
|
||||
THEME_DIR=$(dirname "${x#$dracutsysrootdir}")
|
||||
mkdir -m 0755 -p "${initdir}/$THEME_DIR"
|
||||
inst_multiple "${x#$dracutsysrootdir}"
|
||||
done
|
||||
(
|
||||
cd ${initdir}/usr/share/plymouth/themes;
|
||||
ln -s text/text.plymouth default.plymouth 2>&1;
|
||||
cd ${initdir}/usr/share/plymouth/themes
|
||||
ln -s text/text.plymouth default.plymouth 2>&1
|
||||
)
|
||||
fi
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
if type plymouthd >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
|
||||
if type plymouthd > /dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
|
||||
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -d -n rd_NO_PLYMOUTH; then
|
||||
# first trigger graphics subsystem
|
||||
udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
|
||||
udevadm trigger --action=add --attr-match=class=0x030000 > /dev/null 2>&1
|
||||
# first trigger graphics and tty subsystem
|
||||
udevadm trigger --action=add \
|
||||
--subsystem-match=graphics \
|
||||
--subsystem-match=drm \
|
||||
--subsystem-match=tty \
|
||||
--subsystem-match=acpi \
|
||||
>/dev/null 2>&1
|
||||
> /dev/null 2>&1
|
||||
|
||||
udevadm settle --timeout=180 2>&1 | vinfo
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
|
||||
|
||||
function cms_write_config()
|
||||
{
|
||||
function cms_write_config() {
|
||||
. /tmp/cms.conf
|
||||
SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')"
|
||||
OLDIFS=$IFS
|
||||
|
@ -14,9 +13,9 @@ function cms_write_config()
|
|||
IFS=$OLDIFS
|
||||
devbusid=${subch_array[1]}
|
||||
if [ "$NETTYPE" = "ctc" ]; then
|
||||
driver="ctcm"
|
||||
driver="ctcm"
|
||||
else
|
||||
driver=$NETTYPE
|
||||
driver=$NETTYPE
|
||||
fi
|
||||
|
||||
DEVICE=$(cd /sys/devices/${driver}/$devbusid/net/ && set -- * && [ "$1" != "*" ] && echo $1)
|
||||
|
@ -27,15 +26,15 @@ function cms_write_config()
|
|||
|
||||
strglobin "$IPADDR" '*:*:*' && ipv6=1
|
||||
|
||||
# to please NetworkManager on startup in loader before loader reconfigures net
|
||||
# to please NetworkManager on startup in loader before loader reconfigures net
|
||||
cat > /etc/sysconfig/network << EOF
|
||||
HOSTNAME=$HOSTNAME
|
||||
EOF
|
||||
echo "$HOSTNAME" > /etc/hostname
|
||||
if [ "$ipv6" ]; then
|
||||
echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
|
||||
echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
|
||||
else
|
||||
echo "NETWORKING=yes" >> /etc/sysconfig/network
|
||||
echo "NETWORKING=yes" >> /etc/sysconfig/network
|
||||
fi
|
||||
|
||||
cat > $IFCFGFILE << EOF
|
||||
|
@ -47,14 +46,14 @@ MTU=$MTU
|
|||
SUBCHANNELS=$SUBCHANNELS
|
||||
EOF
|
||||
if [ "$ipv6" ]; then
|
||||
cat >> $IFCFGFILE << EOF
|
||||
cat >> $IFCFGFILE << EOF
|
||||
IPV6INIT=yes
|
||||
IPV6_AUTOCONF=no
|
||||
IPV6ADDR=$IPADDR/$NETMASK
|
||||
IPV6_DEFAULTGW=$GATEWAY
|
||||
EOF
|
||||
else
|
||||
cat >> $IFCFGFILE << EOF
|
||||
cat >> $IFCFGFILE << EOF
|
||||
IPADDR=$IPADDR
|
||||
NETMASK=$NETMASK
|
||||
BROADCAST=$BROADCAST
|
||||
|
@ -62,23 +61,35 @@ GATEWAY=$GATEWAY
|
|||
EOF
|
||||
fi
|
||||
if [ "$ipv6" ]; then
|
||||
DNS1=$(set -- ${DNS/,/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/,/ }; echo $2)
|
||||
DNS1=$(
|
||||
set -- ${DNS/,/ }
|
||||
echo $1
|
||||
)
|
||||
DNS2=$(
|
||||
set -- ${DNS/,/ }
|
||||
echo $2
|
||||
)
|
||||
else
|
||||
DNS1=$(set -- ${DNS/:/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/:/ }; echo $2)
|
||||
DNS1=$(
|
||||
set -- ${DNS/:/ }
|
||||
echo $1
|
||||
)
|
||||
DNS2=$(
|
||||
set -- ${DNS/:/ }
|
||||
echo $2
|
||||
)
|
||||
fi
|
||||
# real DNS config for NetworkManager to generate /etc/resolv.conf
|
||||
# real DNS config for NetworkManager to generate /etc/resolv.conf
|
||||
[ "$DNS1" != "" ] && echo "DNS1=$DNS1" >> $IFCFGFILE
|
||||
[ "$DNS2" != "" ] && echo "DNS2=$DNS2" >> $IFCFGFILE
|
||||
# just to please loader's readNetInfo && writeEnabledNetInfo
|
||||
# which eats DNS1,DNS2,... and generates it themselves based on DNS
|
||||
# just to please loader's readNetInfo && writeEnabledNetInfo
|
||||
# which eats DNS1,DNS2,... and generates it themselves based on DNS
|
||||
if [ "$ipv6" ]; then
|
||||
[ "$DNS" != "" ] && echo "DNS=\"$DNS\"" >> $IFCFGFILE
|
||||
[ "$DNS" != "" ] && echo "DNS=\"$DNS\"" >> $IFCFGFILE
|
||||
else
|
||||
[ "$DNS" != "" ] && echo "DNS=\"${DNS/:/,}\"" >> $IFCFGFILE
|
||||
[ "$DNS" != "" ] && echo "DNS=\"${DNS/:/,}\"" >> $IFCFGFILE
|
||||
fi
|
||||
# colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf
|
||||
# colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf
|
||||
[ "$SEARCHDNS" != "" ] && echo "DOMAIN=\"$SEARCHDNS\"" >> $IFCFGFILE
|
||||
[ "$NETTYPE" != "" ] && echo "NETTYPE=$NETTYPE" >> $IFCFGFILE
|
||||
[ "$PEERID" != "" ] && echo "PEERID=$PEERID" >> $IFCFGFILE
|
||||
|
@ -87,11 +98,11 @@ EOF
|
|||
[ "$MACADDR" != "" ] && echo "MACADDR=$MACADDR" >> $IFCFGFILE
|
||||
optstr=""
|
||||
for option in LAYER2 PORTNO; do
|
||||
[ -z "${!option}" ] && continue
|
||||
[ -n "$optstr" ] && optstr=${optstr}" "
|
||||
optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option}
|
||||
[ -z "${!option}" ] && continue
|
||||
[ -n "$optstr" ] && optstr=${optstr}" "
|
||||
optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option}
|
||||
done
|
||||
# write single quotes since network.py removes double quotes but we need quotes
|
||||
# write single quotes since network.py removes double quotes but we need quotes
|
||||
echo "OPTIONS='$optstr'" >> $IFCFGFILE
|
||||
unset option
|
||||
unset optstr
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
DEVICE=$1
|
||||
|
||||
|
@ -17,17 +17,29 @@ if [ "$ipv6" ] && ! str_starts "$GATEWAY" "["; then
|
|||
fi
|
||||
|
||||
if [ "$ipv6" ]; then
|
||||
DNS1=$(set -- ${DNS/,/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/,/ }; echo $2)
|
||||
DNS1=$(
|
||||
set -- ${DNS/,/ }
|
||||
echo $1
|
||||
)
|
||||
DNS2=$(
|
||||
set -- ${DNS/,/ }
|
||||
echo $2
|
||||
)
|
||||
else
|
||||
DNS1=$(set -- ${DNS/:/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/:/ }; echo $2)
|
||||
DNS1=$(
|
||||
set -- ${DNS/:/ }
|
||||
echo $1
|
||||
)
|
||||
DNS2=$(
|
||||
set -- ${DNS/:/ }
|
||||
echo $2
|
||||
)
|
||||
fi
|
||||
|
||||
{
|
||||
echo "ip=$IPADDR::$GATEWAY:$NETMASK:$HOSTNAME:$DEVICE:none:$MTU:$MACADDR"
|
||||
for i in $DNS1 $DNS2; do
|
||||
echo "nameserver=$i"
|
||||
echo "nameserver=$i"
|
||||
done
|
||||
} > /etc/cmdline.d/80-cms.conf
|
||||
|
||||
|
@ -36,7 +48,7 @@ IFACES="$IFACES $DEVICE"
|
|||
echo "$IFACES" >> /tmp/net.ifaces
|
||||
|
||||
if [ -x /usr/libexec/nm-initrd-generator ]; then
|
||||
type nm_generate_connections >/dev/null 2>&1 || . /lib/nm-lib.sh
|
||||
type nm_generate_connections > /dev/null 2>&1 || . /lib/nm-lib.sh
|
||||
nm_generate_connections
|
||||
else
|
||||
exec ifup "$DEVICE"
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
function sysecho () {
|
||||
function sysecho() {
|
||||
file="$1"
|
||||
shift
|
||||
local i=1
|
||||
while [ $i -le 10 ] ; do
|
||||
while [ $i -le 10 ]; do
|
||||
if [ ! -f "$file" ]; then
|
||||
sleep 1
|
||||
i=$((i+1))
|
||||
i=$((i + 1))
|
||||
else
|
||||
break
|
||||
fi
|
||||
|
@ -27,23 +27,25 @@ function dasd_settle() {
|
|||
return 1
|
||||
fi
|
||||
local i=1
|
||||
while [ $i -le 60 ] ; do
|
||||
while [ $i -le 60 ]; do
|
||||
local status
|
||||
read status < $dasd_status
|
||||
case $status in
|
||||
online|unformatted)
|
||||
return 0 ;;
|
||||
online | unformatted)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
sleep 0.1
|
||||
i=$((i+1)) ;;
|
||||
i=$((i + 1))
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function dasd_settle_all() {
|
||||
for dasdccw in $(while read line || [ -n "$line" ]; do echo "${line%%(*}"; done < /proc/dasd/devices) ; do
|
||||
if ! dasd_settle $dasdccw ; then
|
||||
for dasdccw in $(while read line || [ -n "$line" ]; do echo "${line%%(*}"; done < /proc/dasd/devices); do
|
||||
if ! dasd_settle $dasdccw; then
|
||||
echo $"Could not access DASD $dasdccw in time"
|
||||
return 1
|
||||
fi
|
||||
|
@ -52,8 +54,7 @@ function dasd_settle_all() {
|
|||
}
|
||||
|
||||
# prints a canonocalized device bus ID for a given devno of any format
|
||||
function canonicalize_devno()
|
||||
{
|
||||
function canonicalize_devno() {
|
||||
case ${#1} in
|
||||
3) echo "0.0.0${1}" ;;
|
||||
4) echo "0.0.${1}" ;;
|
||||
|
@ -63,15 +64,14 @@ function canonicalize_devno()
|
|||
}
|
||||
|
||||
# read file from CMS and write it to /tmp
|
||||
function readcmsfile() # $1=dasdport $2=filename
|
||||
{
|
||||
function readcmsfile() { # $1=dasdport $2=filename
|
||||
local dev
|
||||
local numcpus
|
||||
local devname
|
||||
local ret=0
|
||||
if [ $# -ne 2 ]; then return; fi
|
||||
# precondition: udevd created dasda block device node
|
||||
if ! dasd_cio_free -d $1 ; then
|
||||
if ! dasd_cio_free -d $1; then
|
||||
echo $"DASD $1 could not be cleared from device blacklist"
|
||||
return 1
|
||||
fi
|
||||
|
@ -86,9 +86,9 @@ function readcmsfile() # $1=dasdport $2=filename
|
|||
numcpus=$(
|
||||
while read line || [ -n "$line" ]; do
|
||||
if strstr "$line" "# processors"; then
|
||||
echo ${line##*:};
|
||||
break;
|
||||
fi;
|
||||
echo ${line##*:}
|
||||
break
|
||||
fi
|
||||
done < /proc/cpuinfo
|
||||
)
|
||||
|
||||
|
@ -100,7 +100,7 @@ function readcmsfile() # $1=dasdport $2=filename
|
|||
return 1
|
||||
fi
|
||||
udevadm settle
|
||||
if ! dasd_settle $dev ; then
|
||||
if ! dasd_settle $dev; then
|
||||
echo $"Could not access DASD $dev in time"
|
||||
return 1
|
||||
fi
|
||||
|
@ -108,7 +108,11 @@ function readcmsfile() # $1=dasdport $2=filename
|
|||
|
||||
udevadm settle
|
||||
|
||||
devname=$(cd /sys/bus/ccw/devices/$dev/block; set -- *; [ -b /dev/$1 ] && echo $1)
|
||||
devname=$(
|
||||
cd /sys/bus/ccw/devices/$dev/block
|
||||
set -- *
|
||||
[ -b /dev/$1 ] && echo $1
|
||||
)
|
||||
devname=${devname:-dasda}
|
||||
|
||||
[[ -d /mnt ]] || mkdir -p /mnt
|
||||
|
@ -128,7 +132,10 @@ function readcmsfile() # $1=dasdport $2=filename
|
|||
udevadm settle
|
||||
|
||||
# unbind all dasds to unload the dasd modules for a clean start
|
||||
( cd /sys/bus/ccw/drivers/dasd-eckd; for i in *.*; do echo $i > unbind;done)
|
||||
(
|
||||
cd /sys/bus/ccw/drivers/dasd-eckd
|
||||
for i in *.*; do echo $i > unbind; done
|
||||
)
|
||||
udevadm settle
|
||||
modprobe -r dasd_eckd_mod
|
||||
udevadm settle
|
||||
|
@ -139,8 +146,7 @@ function readcmsfile() # $1=dasdport $2=filename
|
|||
return $ret
|
||||
}
|
||||
|
||||
processcmsfile()
|
||||
{
|
||||
processcmsfile() {
|
||||
source /tmp/cms.conf
|
||||
SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')"
|
||||
|
||||
|
@ -183,8 +189,8 @@ processcmsfile()
|
|||
for i in ${!FCP_*}; do
|
||||
echo "${!i}" | while read port rest || [ -n "$port" ]; do
|
||||
case $port in
|
||||
*.*.*)
|
||||
;;
|
||||
*.*.*) ;;
|
||||
|
||||
*.*)
|
||||
port="0.$port"
|
||||
;;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
do_merge() {
|
||||
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 1/' \
|
||||
|
@ -11,8 +11,8 @@ do_merge() {
|
|||
umount -R /sysroot
|
||||
|
||||
for tag in $(getargs rd.lvm.mergetags); do
|
||||
lvm vgs --noheadings -o vg_name | \
|
||||
while read -r vg || [[ -n $vg ]]; do
|
||||
lvm vgs --noheadings -o vg_name \
|
||||
| while read -r vg || [[ -n $vg ]]; do
|
||||
unset LVS
|
||||
declare -a LVS
|
||||
lvs=$(lvm lvs --noheadings -o lv_name "$vg")
|
||||
|
@ -22,7 +22,7 @@ do_merge() {
|
|||
tags=$(trim "$(lvm lvs --noheadings -o lv_tags "$vg/$lv")")
|
||||
strstr ",${tags}," ",${tag}," || continue
|
||||
|
||||
if ! lvm lvs --noheadings -o lv_name "${vg}/${lv}_dracutsnap" &>/dev/null; then
|
||||
if ! lvm lvs --noheadings -o lv_name "${vg}/${lv}_dracutsnap" &> /dev/null; then
|
||||
info "Creating backup ${lv}_dracutsnap of ${vg}/${lv}"
|
||||
lvm lvcreate -pr -s "${vg}/${lv}" --name "${lv}_dracutsnap"
|
||||
fi
|
||||
|
@ -37,7 +37,7 @@ do_merge() {
|
|||
systemctl --no-block stop sysroot.mount
|
||||
udevadm settle
|
||||
|
||||
for ((i=0; i < 100; i++)); do
|
||||
for ((i = 0; i < 100; i++)); do
|
||||
lvm vgchange -an "$vg" && break
|
||||
sleep 0.5
|
||||
done
|
||||
|
@ -58,7 +58,7 @@ do_merge() {
|
|||
systemctl --no-block reset-failed sysroot.mount
|
||||
systemctl --no-block start sysroot.mount
|
||||
|
||||
for ((i=0; i < 100; i++)); do
|
||||
for ((i = 0; i < 100; i++)); do
|
||||
[[ -d /sysroot/dev ]] && break
|
||||
sleep 0.5
|
||||
systemctl --no-block start sysroot.mount
|
||||
|
@ -93,4 +93,3 @@ do_merge() {
|
|||
if getarg rd.lvm.mergetags; then
|
||||
do_merge
|
||||
fi
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
# do not add this module by default
|
||||
# do not add this module by default
|
||||
local arch=${DRACUT_ARCH:-$(uname -m)}
|
||||
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
|
||||
return 0
|
||||
|
@ -13,24 +13,24 @@ check() {
|
|||
cmdline() {
|
||||
local cio_accept
|
||||
|
||||
if [ -e /boot/zipl/active_devices.txt ] ; then
|
||||
while read dev etc ; do
|
||||
[ "$dev" = "#" -o "$dev" = "" ] && continue;
|
||||
if [ -z "$cio_accept" ] ; then
|
||||
if [ -e /boot/zipl/active_devices.txt ]; then
|
||||
while read dev etc; do
|
||||
[ "$dev" = "#" -o "$dev" = "" ] && continue
|
||||
if [ -z "$cio_accept" ]; then
|
||||
cio_accept="$dev"
|
||||
else
|
||||
cio_accept="${cio_accept},${dev}"
|
||||
fi
|
||||
done < /boot/zipl/active_devices.txt
|
||||
fi
|
||||
if [ -n "$cio_accept" ] ; then
|
||||
echo "rd.cio_accept=${cio_accept}"
|
||||
if [ -n "$cio_accept" ]; then
|
||||
echo "rd.cio_accept=${cio_accept}"
|
||||
fi
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
install() {
|
||||
if [[ $hostonly_cmdline == "yes" ]] ; then
|
||||
if [[ $hostonly_cmdline == "yes" ]]; then
|
||||
local _cio_accept=$(cmdline)
|
||||
[[ $_cio_accept ]] && printf "%s\n" "$_cio_accept" >> "${initdir}/etc/cmdline.d/01cio_accept.conf"
|
||||
fi
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
CIO_IGNORE=$(getarg cio_ignore)
|
||||
CIO_ACCEPT=$(getarg rd.cio_accept)
|
||||
|
||||
if [ -z $CIO_IGNORE ] ; then
|
||||
if [ -z $CIO_IGNORE ]; then
|
||||
info "cio_ignored disabled on commandline"
|
||||
return
|
||||
fi
|
||||
if [ -n "$CIO_ACCEPT" ] ; then
|
||||
if [ -n "$CIO_ACCEPT" ]; then
|
||||
OLDIFS="$IFS"
|
||||
IFS=,
|
||||
set -- $CIO_ACCEPT
|
||||
while (($# > 0)) ; do
|
||||
while (($# > 0)); do
|
||||
info "Enabling device $1"
|
||||
cio_ignore --remove $1
|
||||
shift
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
btrfs_check_complete() {
|
||||
local _rootinfo _dev
|
||||
_dev="${1:-/dev/root}"
|
||||
[ -e "$_dev" ] || return 0
|
||||
_rootinfo=$(udevadm info --query=env "--name=$_dev" 2>/dev/null)
|
||||
_rootinfo=$(udevadm info --query=env "--name=$_dev" 2> /dev/null)
|
||||
if strstr "$_rootinfo" "ID_FS_TYPE=btrfs"; then
|
||||
info "Checking, if btrfs device complete"
|
||||
btrfs device ready "$_dev" >/dev/null 2>&1
|
||||
btrfs device ready "$_dev" > /dev/null 2>&1
|
||||
return $?
|
||||
fi
|
||||
return 0
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
btrfs_check_complete() {
|
||||
local _rootinfo _dev
|
||||
_dev="${1:-/dev/root}"
|
||||
[ -e "$_dev" ] || return 0
|
||||
_rootinfo=$(udevadm info --query=env "--name=$_dev" 2>/dev/null)
|
||||
_rootinfo=$(udevadm info --query=env "--name=$_dev" 2> /dev/null)
|
||||
if strstr "$_rootinfo" "ID_FS_TYPE=btrfs"; then
|
||||
info "Checking, if btrfs device complete"
|
||||
unset __btrfs_mount
|
||||
mount -o ro "$_dev" /tmp >/dev/null 2>&1
|
||||
mount -o ro "$_dev" /tmp > /dev/null 2>&1
|
||||
__btrfs_mount=$?
|
||||
[ $__btrfs_mount -eq 0 ] && umount "$_dev" >/dev/null 2>&1
|
||||
[ $__btrfs_mount -eq 0 ] && umount "$_dev" > /dev/null 2>&1
|
||||
return $__btrfs_mount
|
||||
fi
|
||||
return 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
info "Scanning for all btrfs devices"
|
||||
/sbin/btrfs device scan >/dev/null 2>&1
|
||||
/sbin/btrfs device scan > /dev/null 2>&1
|
||||
|
|
|
@ -34,9 +34,11 @@ install() {
|
|||
inst_rules "$moddir/80-btrfs.rules"
|
||||
case "$(btrfs --help)" in
|
||||
*device\ ready*)
|
||||
inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished ;;
|
||||
inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished
|
||||
;;
|
||||
*)
|
||||
inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished ;;
|
||||
inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
# close everything which is not busy
|
||||
rm -f -- /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1
|
||||
rm -f -- /etc/udev/rules.d/70-luks.rules > /dev/null 2>&1
|
||||
|
||||
if ! getarg rd.luks.uuid -d rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS >/dev/null 2>&1; then
|
||||
if ! getarg rd.luks.uuid -d rd_LUKS_UUID > /dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS > /dev/null 2>&1; then
|
||||
while true; do
|
||||
local do_break="y"
|
||||
for i in /dev/mapper/luks-*; do
|
||||
cryptsetup luksClose $i >/dev/null 2>&1 && do_break=n
|
||||
cryptsetup luksClose $i > /dev/null 2>&1 && do_break=n
|
||||
done
|
||||
[ "$do_break" = "y" ] && break
|
||||
done
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v getarg > /dev/null || . /lib/dracut-lib.sh
|
||||
|
||||
# check if the crypttab contains an entry for a LUKS UUID
|
||||
crypttab_contains() {
|
||||
|
@ -49,30 +49,67 @@ crypttab_contains() {
|
|||
# Turn off input echo before tty command is executed and turn on after.
|
||||
# It's useful when password is read from stdin.
|
||||
ask_for_password() {
|
||||
local cmd; local prompt; local tries=3
|
||||
local ply_cmd; local ply_prompt; local ply_tries=3
|
||||
local tty_cmd; local tty_prompt; local tty_tries=3
|
||||
local cmd
|
||||
local prompt
|
||||
local tries=3
|
||||
local ply_cmd
|
||||
local ply_prompt
|
||||
local ply_tries=3
|
||||
local tty_cmd
|
||||
local tty_prompt
|
||||
local tty_tries=3
|
||||
local ret
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--cmd) ply_cmd="$2"; tty_cmd="$2"; shift;;
|
||||
--ply-cmd) ply_cmd="$2"; shift;;
|
||||
--tty-cmd) tty_cmd="$2"; shift;;
|
||||
--prompt) ply_prompt="$2"; tty_prompt="$2"; shift;;
|
||||
--ply-prompt) ply_prompt="$2"; shift;;
|
||||
--tty-prompt) tty_prompt="$2"; shift;;
|
||||
--tries) ply_tries="$2"; tty_tries="$2"; shift;;
|
||||
--ply-tries) ply_tries="$2"; shift;;
|
||||
--tty-tries) tty_tries="$2"; shift;;
|
||||
--tty-echo-off) tty_echo_off=yes;;
|
||||
--cmd)
|
||||
ply_cmd="$2"
|
||||
tty_cmd="$2"
|
||||
shift
|
||||
;;
|
||||
--ply-cmd)
|
||||
ply_cmd="$2"
|
||||
shift
|
||||
;;
|
||||
--tty-cmd)
|
||||
tty_cmd="$2"
|
||||
shift
|
||||
;;
|
||||
--prompt)
|
||||
ply_prompt="$2"
|
||||
tty_prompt="$2"
|
||||
shift
|
||||
;;
|
||||
--ply-prompt)
|
||||
ply_prompt="$2"
|
||||
shift
|
||||
;;
|
||||
--tty-prompt)
|
||||
tty_prompt="$2"
|
||||
shift
|
||||
;;
|
||||
--tries)
|
||||
ply_tries="$2"
|
||||
tty_tries="$2"
|
||||
shift
|
||||
;;
|
||||
--ply-tries)
|
||||
ply_tries="$2"
|
||||
shift
|
||||
;;
|
||||
--tty-tries)
|
||||
tty_tries="$2"
|
||||
shift
|
||||
;;
|
||||
--tty-echo-off) tty_echo_off=yes ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
{ flock -s 9;
|
||||
{
|
||||
flock -s 9
|
||||
# Prompt for password with plymouth, if installed and running.
|
||||
if type plymouth >/dev/null 2>&1 && plymouth --ping 2>/dev/null; then
|
||||
if type plymouth > /dev/null 2>&1 && plymouth --ping 2> /dev/null; then
|
||||
plymouth ask-for-password \
|
||||
--prompt "$ply_prompt" --number-of-tries=$ply_tries \
|
||||
--command="$ply_cmd"
|
||||
|
@ -85,17 +122,17 @@ ask_for_password() {
|
|||
|
||||
local i=1
|
||||
while [ $i -le $tty_tries ]; do
|
||||
[ -n "$tty_prompt" ] && \
|
||||
printf "$tty_prompt [$i/$tty_tries]:" >&2
|
||||
[ -n "$tty_prompt" ] \
|
||||
&& printf "$tty_prompt [$i/$tty_tries]:" >&2
|
||||
eval "$tty_cmd" && ret=0 && break
|
||||
ret=$?
|
||||
i=$(($i+1))
|
||||
i=$(($i + 1))
|
||||
[ -n "$tty_prompt" ] && printf '\n' >&2
|
||||
done
|
||||
|
||||
[ "$tty_echo_off" = yes ] && stty $stty_orig
|
||||
fi
|
||||
} 9>/.console_lock
|
||||
} 9> /.console_lock
|
||||
|
||||
[ $ret -ne 0 ] && echo "Wrong password" >&2
|
||||
return $ret
|
||||
|
@ -107,14 +144,17 @@ ask_for_password() {
|
|||
# example:
|
||||
# test_dev -f LABEL="nice label" /some/file1
|
||||
test_dev() {
|
||||
local test_op=$1; local dev="$2"; local f="$3"
|
||||
local ret=1; local mount_point=$(mkuniqdir /mnt testdev)
|
||||
local test_op=$1
|
||||
local dev="$2"
|
||||
local f="$3"
|
||||
local ret=1
|
||||
local mount_point=$(mkuniqdir /mnt testdev)
|
||||
local path
|
||||
|
||||
[ -n "$dev" -a -n "$*" ] || return 1
|
||||
[ -d "$mount_point" ] || die 'Mount point does not exist!'
|
||||
|
||||
if mount -r "$dev" "$mount_point" >/dev/null 2>&1; then
|
||||
if mount -r "$dev" "$mount_point" > /dev/null 2>&1; then
|
||||
test $test_op "${mount_point}/${f}"
|
||||
ret=$?
|
||||
umount "$mount_point"
|
||||
|
@ -139,7 +179,8 @@ test_dev() {
|
|||
# Returns true if /dev/dm-1 UUID starts with "123".
|
||||
match_dev() {
|
||||
[ -z "$1" -o "$1" = '*' ] && return 0
|
||||
local devlist; local dev
|
||||
local devlist
|
||||
local dev
|
||||
|
||||
devlist="$(devnames "$1")" || return 255
|
||||
dev="$(devnames "$2")" || return 255
|
||||
|
@ -162,8 +203,11 @@ $dev
|
|||
# May print:
|
||||
# /dev/sdc1:/keys/some.key
|
||||
getkey() {
|
||||
local keys_file="$1"; local for_dev="$2"
|
||||
local luks_dev; local key_dev; local key_path
|
||||
local keys_file="$1"
|
||||
local for_dev="$2"
|
||||
local luks_dev
|
||||
local key_dev
|
||||
local key_path
|
||||
|
||||
[ -z "$keys_file" -o -z "$for_dev" ] && die 'getkey: wrong usage!'
|
||||
[ -f "$keys_file" ] || return 1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
|
||||
type crypttab_contains > /dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
|
||||
|
||||
dev=$1
|
||||
luks=$2
|
||||
|
@ -24,7 +24,7 @@ fi
|
|||
|
||||
echo "$luks $dev - timeout=0,$allowdiscards" >> /etc/crypttab
|
||||
|
||||
if command -v systemctl >/dev/null; then
|
||||
if command -v systemctl > /dev/null; then
|
||||
systemctl daemon-reload
|
||||
systemctl start cryptsetup.target
|
||||
fi
|
||||
|
|
|
@ -157,7 +157,7 @@ else
|
|||
info "No key found for $device. Will try $numtries time(s) more later."
|
||||
initqueue --unique --onetime --settled \
|
||||
--name cryptroot-ask-$luksname \
|
||||
$(command -v cryptroot-ask) "$device" "$luksname" "$is_keysource" "$(($numtries-1))"
|
||||
$(command -v cryptroot-ask) "$device" "$luksname" "$is_keysource" "$(($numtries - 1))"
|
||||
exit 0
|
||||
fi
|
||||
unset tmp
|
||||
|
|
|
@ -46,7 +46,7 @@ installkernel() {
|
|||
IFS=$_OLD_IFS
|
||||
# try to load the cipher part with "crypto-" prepended
|
||||
# in non-hostonly mode
|
||||
hostonly= instmods $(for k in "$@"; do echo "crypto-$k";done)
|
||||
hostonly= instmods $(for k in "$@"; do echo "crypto-$k"; done)
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ cmdline() {
|
|||
UUID=$(
|
||||
blkid -u crypto -o export $dev \
|
||||
| while read line || [ -n "$line" ]; do
|
||||
[[ ${line#UUID} = $line ]] && continue
|
||||
printf "%s" "${line#UUID=}"
|
||||
break
|
||||
done
|
||||
[[ ${line#UUID} = $line ]] && continue
|
||||
printf "%s" "${line#UUID=}"
|
||||
break
|
||||
done
|
||||
)
|
||||
[[ ${UUID} ]] || continue
|
||||
printf "%s" " rd.luks.uuid=luks-${UUID}"
|
||||
|
@ -95,14 +95,14 @@ install() {
|
|||
[[ $_mapper = \#* ]] && continue
|
||||
[[ $_dev ]] || continue
|
||||
|
||||
[[ $_dev == PARTUUID=* ]] && \
|
||||
_dev="/dev/disk/by-partuuid/${_dev#PARTUUID=}"
|
||||
[[ $_dev == PARTUUID=* ]] \
|
||||
&& _dev="/dev/disk/by-partuuid/${_dev#PARTUUID=}"
|
||||
|
||||
[[ $_dev == UUID=* ]] && \
|
||||
_dev="/dev/disk/by-uuid/${_dev#UUID=}"
|
||||
[[ $_dev == UUID=* ]] \
|
||||
&& _dev="/dev/disk/by-uuid/${_dev#UUID=}"
|
||||
|
||||
[[ $_dev == ID=* ]] && \
|
||||
_dev="/dev/disk/by-id/${_dev#ID=}"
|
||||
[[ $_dev == ID=* ]] \
|
||||
&& _dev="/dev/disk/by-id/${_dev#ID=}"
|
||||
|
||||
echo "$_dev $(blkid $_dev -s UUID -o value)" >> "${initdir}/etc/block_uuid.map"
|
||||
|
||||
|
@ -147,15 +147,15 @@ install() {
|
|||
# the cryptsetup targets are already pulled in by 00systemd, but not
|
||||
# the enablement symlinks
|
||||
inst_multiple -o \
|
||||
$systemdutildir/system-generators/systemd-cryptsetup-generator \
|
||||
$systemdutildir/systemd-cryptsetup \
|
||||
$systemdsystemunitdir/systemd-ask-password-console.path \
|
||||
$systemdsystemunitdir/systemd-ask-password-console.service \
|
||||
$systemdsystemunitdir/cryptsetup.target \
|
||||
$systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
|
||||
$systemdsystemunitdir/remote-cryptsetup.target \
|
||||
$systemdsystemunitdir/initrd-root-device.target.wants/remote-cryptsetup.target \
|
||||
systemd-ask-password systemd-tty-ask-password-agent
|
||||
$systemdutildir/system-generators/systemd-cryptsetup-generator \
|
||||
$systemdutildir/systemd-cryptsetup \
|
||||
$systemdsystemunitdir/systemd-ask-password-console.path \
|
||||
$systemdsystemunitdir/systemd-ask-password-console.service \
|
||||
$systemdsystemunitdir/cryptsetup.target \
|
||||
$systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
|
||||
$systemdsystemunitdir/remote-cryptsetup.target \
|
||||
$systemdsystemunitdir/initrd-root-device.target.wants/remote-cryptsetup.target \
|
||||
systemd-ask-password systemd-tty-ask-password-agent
|
||||
fi
|
||||
|
||||
dracut_need_initqueue
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
type crypttab_contains >/dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
|
||||
|
||||
type crypttab_contains > /dev/null 2>&1 || . /lib/dracut-crypt-lib.sh
|
||||
|
||||
_cryptgetargsname() {
|
||||
debug_off
|
||||
|
@ -12,15 +11,15 @@ _cryptgetargsname() {
|
|||
set --
|
||||
for _o in $(getargs rd.luks.name); do
|
||||
if [ "${_o%=*}" = "${_key%=}" ]; then
|
||||
[ -n "${_o%=*}" ] && set -- "$@" "${_o#*=}";
|
||||
_found=1;
|
||||
[ -n "${_o%=*}" ] && set -- "$@" "${_o#*=}"
|
||||
_found=1
|
||||
fi
|
||||
done
|
||||
if [ -n "$_found" ]; then
|
||||
[ $# -gt 0 ] && printf '%s' "$*"
|
||||
return 0
|
||||
fi
|
||||
return 1;
|
||||
return 1
|
||||
}
|
||||
|
||||
if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
if getargbool 1 rd.luks -n rd_NO_LUKS && \
|
||||
[ -n "$(getarg rd.luks.key)" ]; then
|
||||
exec 7>/etc/udev/rules.d/65-luks-keydev.rules
|
||||
if getargbool 1 rd.luks -n rd_NO_LUKS \
|
||||
&& [ -n "$(getarg rd.luks.key)" ]; then
|
||||
exec 7> /etc/udev/rules.d/65-luks-keydev.rules
|
||||
echo 'SUBSYSTEM!="block", GOTO="luks_keydev_end"' >&7
|
||||
echo 'ACTION!="add|change", GOTO="luks_keydev_end"' >&7
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
. /lib/dracut-crypt-lib.sh
|
||||
|
||||
|
||||
real_keydev="$1"; keypath="$2"; luksdev="$3"
|
||||
real_keydev="$1"
|
||||
keypath="$2"
|
||||
luksdev="$3"
|
||||
|
||||
[ -z "$real_keydev" -o -z "$keypath" ] && die 'probe-keydev: wrong usage!'
|
||||
[ -z "$luksdev" ] && luksdev='*'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
strstr "$(cat /proc/misc)" device-mapper || modprobe dm_mod
|
||||
modprobe dm_mirror 2>/dev/null
|
||||
modprobe dm_mirror 2> /dev/null
|
||||
|
|
|
@ -5,7 +5,7 @@ _remove_dm() {
|
|||
local s
|
||||
local devname
|
||||
|
||||
for s in /sys/block/${dev}/holders/dm-* ; do
|
||||
for s in /sys/block/${dev}/holders/dm-*; do
|
||||
[ -e ${s} ] || continue
|
||||
_remove_dm ${s##*/}
|
||||
done
|
||||
|
@ -30,12 +30,12 @@ _do_dm_shutdown() {
|
|||
local dev
|
||||
|
||||
info "Disassembling device-mapper devices"
|
||||
for dev in /sys/block/dm-* ; do
|
||||
for dev in /sys/block/dm-*; do
|
||||
[ -e ${dev} ] || continue
|
||||
if [ "x$final" != "x" ]; then
|
||||
_remove_dm ${dev##*/} || ret=$?
|
||||
else
|
||||
_remove_dm ${dev##*/} >/dev/null 2>&1 || ret=$?
|
||||
_remove_dm ${dev##*/} > /dev/null 2>&1 || ret=$?
|
||||
fi
|
||||
done
|
||||
if [ "x$final" != "x" ]; then
|
||||
|
@ -45,8 +45,8 @@ _do_dm_shutdown() {
|
|||
return $ret
|
||||
}
|
||||
|
||||
if command -v dmsetup >/dev/null &&
|
||||
[ "x$(dmsetup status)" != "xNo devices found" ]; then
|
||||
if command -v dmsetup > /dev/null \
|
||||
&& [ "x$(dmsetup status)" != "xNo devices found" ]; then
|
||||
_do_dm_shutdown $1
|
||||
else
|
||||
:
|
||||
|
|
|
@ -18,8 +18,8 @@ installkernel() {
|
|||
|
||||
# called by dracut
|
||||
install() {
|
||||
modinfo -k "$kernel" dm_mod >/dev/null 2>&1 && \
|
||||
inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh"
|
||||
modinfo -k "$kernel" dm_mod > /dev/null 2>&1 \
|
||||
&& inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh"
|
||||
|
||||
inst_multiple dmsetup
|
||||
inst_multiple -o dmeventd
|
||||
|
@ -40,4 +40,3 @@ install() {
|
|||
|
||||
inst_hook shutdown 25 "$moddir/dm-shutdown.sh"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
dev="$1"
|
||||
devenc=$(str_replace "$1" '/' '\2f')
|
||||
|
||||
[ -e /tmp/dmraid.$devenc ] && exit 0
|
||||
|
||||
>/tmp/dmraid.$devenc
|
||||
> /tmp/dmraid.$devenc
|
||||
|
||||
DM_RAIDS=$(getargs rd.dm.uuid -d rd_DM_UUID=)
|
||||
|
||||
|
@ -24,10 +24,10 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
|
|||
fi
|
||||
|
||||
info "Found dmraid sets:"
|
||||
echo $SETS|vinfo
|
||||
echo $SETS | vinfo
|
||||
|
||||
if [ -n "$DM_RAIDS" ]; then
|
||||
# only activate specified DM RAIDS
|
||||
# only activate specified DM RAIDS
|
||||
for r in $DM_RAIDS; do
|
||||
for s in $SETS; do
|
||||
if [ "${s##$r}" != "$s" ]; then
|
||||
|
@ -37,7 +37,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
|
|||
done
|
||||
done
|
||||
else
|
||||
# scan and activate all DM RAIDS
|
||||
# scan and activate all DM RAIDS
|
||||
for s in $SETS; do
|
||||
info "Activating $s"
|
||||
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
|
||||
|
|
|
@ -47,7 +47,7 @@ cmdline() {
|
|||
for holder in "$DEVPATH"/holders/*; do
|
||||
[[ -e "$holder" ]] || continue
|
||||
dev="/dev/${holder##*/}"
|
||||
DM_NAME="$(dmsetup info -c --noheadings -o name "$dev" 2>/dev/null)"
|
||||
DM_NAME="$(dmsetup info -c --noheadings -o name "$dev" 2> /dev/null)"
|
||||
[[ ${DM_NAME} ]] && break
|
||||
done
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue