reformat source code

removed tabs and set indention to 4 spaces
added emacs and vi format headers
master
Harald Hoyer 2010-09-10 15:23:06 +02:00
parent d95d2f3b44
commit cc02093d69
173 changed files with 1835 additions and 1448 deletions

178
dracut
View File

@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# Generator script for a dracut initramfs # Generator script for a dracut initramfs
# Tries to retain some degree of compatibility with the command line # Tries to retain some degree of compatibility with the command line
# of the various mkinitrd implementations out there # of the various mkinitrd implementations out there
# #


# Copyright 2005-2009 Red Hat, Inc. All rights reserved. # Copyright 2005-2010 Red Hat, Inc. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -24,7 +26,8 @@


usage() { usage() {
# 80x25 linebreak here ^ # 80x25 linebreak here ^
echo "Usage: $0 [OPTION]... <initramfs> <kernel-version> cat << EOF
Usage: $0 [OPTION]... <initramfs> <kernel-version>
Creates initial ramdisk images for preloading modules Creates initial ramdisk images for preloading modules


-f, --force Overwrite existing initramfs file. -f, --force Overwrite existing initramfs file.
@ -48,21 +51,21 @@ Creates initial ramdisk images for preloading modules
--no-kernel Do not install kernel drivers and firmware files --no-kernel Do not install kernel drivers and firmware files
--ignore-kernel-modules --ignore-kernel-modules
Don't try to load modules. It automatically implies Don't try to load modules. It automatically implies
'--no-kernel'. It's assumed that everything needed '--no-kernel'. It's assumed that everything needed
is built into kernel. is built into kernel.
--strip Strip binaries in the initramfs --strip Strip binaries in the initramfs
--nostrip Do not strip binaries in the initramfs (default) --nostrip Do not strip binaries in the initramfs (default)
--mdadmconf Include local /etc/mdadm.conf --mdadmconf Include local /etc/mdadm.conf
--nomdadmconf Do not include local /etc/mdadm.conf --nomdadmconf Do not include local /etc/mdadm.conf
--lvmconf Include local /etc/lvm/lvm.conf --lvmconf Include local /etc/lvm/lvm.conf
--nolvmconf Do not include local /etc/lvm/lvm.conf --nolvmconf Do not include local /etc/lvm/lvm.conf
-h, --help This message -h, --help This message
--debug Output debug information of the build process --debug Output debug information of the build process
-v, --verbose Verbose output during the build process -v, --verbose Verbose output during the build process
-c, --conf [FILE] Specify configuration file to use. -c, --conf [FILE] Specify configuration file to use.
Default: /etc/dracut.conf Default: /etc/dracut.conf
--confdir [DIR] Specify configuration directory to use *.conf files from. --confdir [DIR] Specify configuration directory to use *.conf files
Default: /etc/dracut.conf.d from. Default: /etc/dracut.conf.d
-l, --local Local mode. Use modules from the current working -l, --local Local mode. Use modules from the current working
directory instead of the system-wide installed in directory instead of the system-wide installed in
/usr/share/dracut/modules.d. /usr/share/dracut/modules.d.
@ -76,17 +79,17 @@ Creates initial ramdisk images for preloading modules
-I, --install [LIST] Install the space separated list of files into the -I, --install [LIST] Install the space separated list of files into the
initramfs. initramfs.
--gzip Compress the generated initramfs using gzip. --gzip Compress the generated initramfs using gzip.
This will be done by default, unless another This will be done by default, unless another
compression option or --no-compress is passed. compression option or --no-compress is passed.
--bzip2 Compress the generated initramfs using bzip2. --bzip2 Compress the generated initramfs using bzip2.
Make sure your kernel has bzip2 decompression support Make sure your kernel has bzip2 decompression support
compiled in, otherwise you will not be able to boot. compiled in, otherwise you will not be able to boot.
--lzma Compress the generated initramfs using lzma. --lzma Compress the generated initramfs using lzma.
Make sure your kernel has lzma support compiled in, Make sure your kernel has lzma support compiled in,
otherwise you will not be able to boot. otherwise you will not be able to boot.
--no-compress Do not compress the generated initramfs. This will --no-compress Do not compress the generated initramfs. This will
override any other compression options. override any other compression options.
" EOF
} }


# Little helper function for reading args from the commandline. # Little helper function for reading args from the commandline.
@ -98,44 +101,44 @@ read_arg() {
# $3 = arg parameter # $3 = arg parameter
local rematch='^[^=]*=(.*)$' local rematch='^[^=]*=(.*)$'
if [[ $2 =~ $rematch ]]; then if [[ $2 =~ $rematch ]]; then
read "$1" <<< "${BASH_REMATCH[1]}" read "$1" <<< "${BASH_REMATCH[1]}"
else else
read "$1" <<< "$3" read "$1" <<< "$3"
# There is no way to shift our callers args, so # There is no way to shift our callers args, so
# return 1 to indicate they should do it instead. # return 1 to indicate they should do it instead.
return 1 return 1
fi fi
} }


while (($# > 0)); do while (($# > 0)); do
case ${1%%=*} in case ${1%%=*} in
-m|--modules) read_arg dracutmodules_l "$@" || shift;; -m|--modules) read_arg dracutmodules_l "$@" || shift;;
-o|--omit) read_arg omit_dracutmodules_l "$@" || shift;; -o|--omit) read_arg omit_dracutmodules_l "$@" || shift;;
-a|--add) read_arg add_dracutmodules_l "$@" || shift;; -a|--add) read_arg add_dracutmodules_l "$@" || shift;;
-d|--drivers) read_arg drivers_l "$@" || shift;; -d|--drivers) read_arg drivers_l "$@" || shift;;
--add-drivers) read_arg add_drivers_l "$@" || shift;; --add-drivers) read_arg add_drivers_l "$@" || shift;;
--filesystems) read_arg filesystems_l "$@" || shift;; --filesystems) read_arg filesystems_l "$@" || shift;;
-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;; -k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
-c|--conf) read_arg conffile "$@" || shift;; -c|--conf) read_arg conffile "$@" || shift;;
--confdir) read_arg confdir "$@" || shift;; --confdir) read_arg confdir "$@" || shift;;
-I|--install) read_arg install_items "$@" || shift;; -I|--install) read_arg install_items "$@" || shift;;
--fwdir) read_arg fw_dir_l "$@" || shift;; --fwdir) read_arg fw_dir_l "$@" || shift;;
-f|--force) force=yes;; -f|--force) force=yes;;
--kernel-only) kernel_only="yes"; no_kernel="no";; --kernel-only) kernel_only="yes"; no_kernel="no";;
--no-kernel) kernel_only="no"; no_kernel="yes";; --no-kernel) kernel_only="no"; no_kernel="yes";;
--strip) do_strip_l="yes";; --strip) do_strip_l="yes";;
--nostrip) do_strip_l="no";; --nostrip) do_strip_l="no";;
--mdadmconf) mdadmconf_l="yes";; --mdadmconf) mdadmconf_l="yes";;
--nomdadmconf) mdadmconf_l="no";; --nomdadmconf) mdadmconf_l="no";;
--lvmconf) lvmconf_l="yes";; --lvmconf) lvmconf_l="yes";;
--nolvmconf) lvmconf_l="no";; --nolvmconf) lvmconf_l="no";;
--debug) debug="yes";; --debug) debug="yes";;
-v|--verbose) beverbose="yes";; -v|--verbose) beverbose="yes";;
-l|--local) allowlocal="yes" ;; -l|--local) allowlocal="yes" ;;
-H|--hostonly) hostonly_l="yes" ;; -H|--hostonly) hostonly_l="yes" ;;
--fstab) use_fstab_l="yes" ;; --fstab) use_fstab_l="yes" ;;
-h|--help) usage; exit 1 ;; -h|--help) usage; exit 1 ;;
-i|--include) include_src="$2"; include_target="$3"; shift 2;; -i|--include) include_src="$2"; include_target="$3"; shift 2;;
--bzip2) [[ $compress != cat ]] && compress="bzip2 -9";; --bzip2) [[ $compress != cat ]] && compress="bzip2 -9";;
--lzma) [[ $compress != cat ]] && compress="lzma -9";; --lzma) [[ $compress != cat ]] && compress="lzma -9";;
--no-compress) compress="cat";; --no-compress) compress="cat";;
@ -147,8 +150,8 @@ while (($# > 0)); do
ignore_kmodules="yes" ignore_kmodules="yes"
omit_dracutmodules_l+=\ kernel-modules omit_dracutmodules_l+=\ kernel-modules
;; ;;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;; -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
*) break ;; *) break ;;
esac esac
shift shift
done done
@ -163,7 +166,8 @@ export PATH


[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut [[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut


[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && dracutbasedir="${0%/*}" [[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && \
dracutbasedir="${0%/*}"


# if we were not passed a config file, try the default one # if we were not passed a config file, try the default one
if [[ ! -f $conffile ]]; then if [[ ! -f $conffile ]]; then
@ -182,7 +186,7 @@ fi
# source our config dir # source our config dir
if [[ $confdir && -d $confdir ]]; then if [[ $confdir && -d $confdir ]]; then
for f in "$confdir"/*.conf; do for f in "$confdir"/*.conf; do
[[ -e $f ]] && . "$f" [[ -e $f ]] && . "$f"
done done
fi fi


@ -213,11 +217,12 @@ fw_dir=${fw_dir//:/ }
[[ $compress ]] || compress="gzip -9" [[ $compress ]] || compress="gzip -9"


if [[ -f $dracutbasedir/dracut-functions ]]; then if [[ -f $dracutbasedir/dracut-functions ]]; then
. $dracutbasedir/dracut-functions . $dracutbasedir/dracut-functions
else else
echo "Cannot find $dracutbasedir/dracut-functions. Are you running from a git checkout?" echo "Cannot find $dracutbasedir/dracut-functions."
echo "Try passing -l as an argument to $0" echo "Are you running from a git checkout?"
exit 1 echo "Try passing -l as an argument to $0"
exit 1
fi fi


dracutfunctions=$dracutbasedir/dracut-functions dracutfunctions=$dracutbasedir/dracut-functions
@ -270,13 +275,16 @@ elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
exit 1 exit 1
fi fi


hookdirs="cmdline pre-udev pre-trigger netroot pre-mount pre-pivot mount emergency" hookdirs="cmdline pre-udev pre-trigger netroot pre-mount"
hookdirs+=" pre-pivot mount emergency"


[[ $TMPDIR && ! -w $TMPDIR ]] && unset TMPDIR [[ $TMPDIR && ! -w $TMPDIR ]] && unset TMPDIR
readonly initdir=$(mktemp -d -t initramfs.XXXXXX) readonly initdir=$(mktemp -d -t initramfs.XXXXXX)


trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT # clean up after ourselves no matter how we die. # clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT # clean up after ourselves no matter how we die. trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT


# Need to be able to have non-root users read stuff (rpcbind etc) # Need to be able to have non-root users read stuff (rpcbind etc)
chmod 755 "$initdir" chmod 755 "$initdir"
@ -288,29 +296,30 @@ export initdir hookdirs dracutbasedir dracutmodules drivers \


if [[ $kernel_only != yes ]]; then if [[ $kernel_only != yes ]]; then
# Create some directory structure first # Create some directory structure first
for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot tmp dev/pts var/run; do for d in bin sbin usr/bin usr/sbin usr/lib etc \
inst_dir "/$d"; proc sys sysroot tmp dev/pts var/run; do
inst_dir "/$d";
done done
fi fi


# check all our modules to see if they should be sourced. # check all our modules to see if they should be sourced.
# This builds a list of modules that we will install next. # This builds a list of modules that we will install next.
check_modules check_modules

# source our modules. # source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
mod=${moddir##*/}; mod=${mod#[0-9][0-9]} mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
if strstr "$mods_to_load" " $mod "; then if strstr "$mods_to_load" " $mod "; then
dinfo "*** Sourcing module $mod" dinfo "*** Sourcing module $mod"
if [[ $kernel_only = yes ]]; then if [[ $kernel_only = yes ]]; then
[[ -x $moddir/installkernel ]] && . "$moddir/installkernel" [[ -x $moddir/installkernel ]] && . "$moddir/installkernel"
else else
. "$moddir/install" . "$moddir/install"
if [[ $no_kernel != yes && -x $moddir/installkernel ]]; then if [[ $no_kernel != yes && -x $moddir/installkernel ]]; then
. "$moddir/installkernel" . "$moddir/installkernel"
fi fi
fi fi
mods_to_load=${mods_to_load// $mod /} mods_to_load=${mods_to_load// $mod /}
fi fi
done done
unset moddir unset moddir
@ -330,45 +339,38 @@ if [[ $include_src && $include_target ]]; then
fi fi


for item in $install_items; do for item in $install_items; do
dracut_install "$item" dracut_install "$item"
done done
unset item unset item


# make sure that library links are correct and up to date # make sure that library links are correct and up to date
cp -ar /etc/ld.so.conf* "$initdir"/etc cp -ar /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir" || [[ $UID != "0" ]] && dinfo "ldconfig might need uid=0 (root) for chroot()" ldconfig -r "$initdir" || [[ $UID != "0" ]] && \
dinfo "ldconfig might need uid=0 (root) for chroot()"


[[ $beverbose = yes ]] && (du -c "$initdir" | sort -n) [[ $beverbose = yes ]] && (du -c "$initdir" | sort -n)


# strip binaries # strip binaries
if [[ $do_strip = yes ]] ; then if [[ $do_strip = yes ]] ; then
for p in strip grep find; do for p in strip grep find; do
if ! type -P $p >/dev/null; then if ! type -P $p >/dev/null; then
derror "Could not find '$p'. You should run $0 with '--nostrip'." derror "Could not find '$p'. You should run $0 with '--nostrip'."
do_strip=no do_strip=no
fi fi
done done
fi fi


if [[ $do_strip = yes ]] ; then if [[ $do_strip = yes ]] ; then
for f in $(find "$initdir" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 -or -path '*/lib/modules/*.ko' \) ); do for f in $(find "$initdir" -type f \
dinfo "Stripping $f" \( -perm -0100 -or -perm -0010 -or -perm -0001 \
strip -g "$f" 2>/dev/null|| : -or -path '*/lib/modules/*.ko' \) ); do
# dinfo "Stripping $f"
# FIXME: only strip -g for now strip -g "$f" 2>/dev/null|| :
#
#strip -g --strip-unneeded "$f" || :
#note="-R .note"
#if objdump -h $f | grep '^[ ]*[0-9]*[ ]*.note[ ]' -A 1 | \
# grep -q ALLOC; then
# note=
#fi
#strip -R .comment $note "$f" || :
done done
fi fi


type hardlink &>/dev/null && { type hardlink &>/dev/null && {
hardlink "$initdir" 2>&1 hardlink "$initdir" 2>&1
} }


if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \ if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \

View File

@ -1,5 +1,7 @@
#!/bin/bash --norc #!/bin/bash --norc

# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# Copyright 2009 Red Hat, Inc. All rights reserved. # Copyright 2009 Red Hat, Inc. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -31,7 +33,8 @@ derror() {


usage() { usage() {
# 80x25 linebreak here ^ # 80x25 linebreak here ^
echo "Usage: $0 [OPTION]... <initramfs> <base image> [<image>...] cat << EOF
Usage: $0 [OPTION]... <initramfs> <base image> [<image>...]
Creates initial ramdisk image by concatenating several images from the command Creates initial ramdisk image by concatenating several images from the command
line and /boot/dracut/ line and /boot/dracut/


@ -45,7 +48,7 @@ line and /boot/dracut/
-h, --help This message -h, --help This message
--debug Output debug information of the build process --debug Output debug information of the build process
-v, --verbose Verbose output during the build process -v, --verbose Verbose output during the build process
" EOF
} }




@ -54,16 +57,16 @@ overlay=/var/lib/dracut/overlay


while (($# > 0)); do while (($# > 0)); do
case $1 in case $1 in
-f|--force) force=yes;; -f|--force) force=yes;;
-i|--imagedir) imagedir=$2;shift;; -i|--imagedir) imagedir=$2;shift;;
-o|--overlaydir) overlay=$2;shift;; -o|--overlaydir) overlay=$2;shift;;
--nooverlay) no_overlay=yes;shift;; --nooverlay) no_overlay=yes;shift;;
--noimagedir) no_imagedir=yes;shift;; --noimagedir) no_imagedir=yes;shift;;
-h|--help) usage; exit 1 ;; -h|--help) usage; exit 1 ;;
--debug) debug="yes";; --debug) debug="yes";;
-v|--verbose) beverbose="yes";; -v|--verbose) beverbose="yes";;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;; -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
*) break ;; *) break ;;
esac esac
shift shift
done done
@ -108,7 +111,7 @@ fi


if [[ ! $no_imagedir ]]; then if [[ ! $no_imagedir ]]; then
for i in "$imagedir/"*.img; do for i in "$imagedir/"*.img; do
[[ -f $i ]] && images+=("$i") [[ -f $i ]] && images+=("$i")
done done
fi fi



View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# functions used by dracut and other tools. # functions used by dracut and other tools.
# #
@ -58,8 +60,8 @@ vercmp() {
# Log initrd creation. # Log initrd creation.
if ! [[ $dracutlogfile ]]; then if ! [[ $dracutlogfile ]]; then
[[ $dracutbasedir = /usr/share/dracut ]] && \ [[ $dracutbasedir = /usr/share/dracut ]] && \
dracutlogfile=/var/log/dracut.log || \ dracutlogfile=/var/log/dracut.log || \
dracutlogfile=/tmp/dracut.log dracutlogfile=/tmp/dracut.log
# [[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log # [[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
if [[ -w $dracutlogfile ]]; then if [[ -w $dracutlogfile ]]; then
>"$dracutlogfile" >"$dracutlogfile"
@ -99,21 +101,21 @@ get_fs_env() {
[[ $ID_FS_TYPE ]] && return [[ $ID_FS_TYPE ]] && return


if [[ -x /lib/udev/vol_id ]]; then if [[ -x /lib/udev/vol_id ]]; then
eval $(/lib/udev/vol_id --export $1) eval $(/lib/udev/vol_id --export $1)
elif find_binary blkid >/dev/null; then elif find_binary blkid >/dev/null; then
eval $(blkid -o udev $1) eval $(blkid -o udev $1)
else else
return 1 return 1
fi fi
} }


get_fs_type() ( get_fs_type() (
[[ $1 ]] || return [[ $1 ]] || return
if [[ $1 != ${1#/dev/block/nfs:} ]] \ if [[ $1 != ${1#/dev/block/nfs:} ]] \
|| [[ $1 != ${1#/dev/block/nfs3:} ]] \ || [[ $1 != ${1#/dev/block/nfs3:} ]] \
|| [[ $1 != ${1#/dev/block/nfs4:} ]]; then || [[ $1 != ${1#/dev/block/nfs4:} ]]; then
echo "nfs" echo "nfs"
return return
fi fi
get_fs_env $1 || return get_fs_env $1 || return
echo $ID_FS_TYPE echo $ID_FS_TYPE
@ -127,32 +129,32 @@ get_fs_uuid() (
# finds the major:minor of the block device backing the root filesystem. # finds the major:minor of the block device backing the root filesystem.
find_block_device() { find_block_device() {
local x mpt majmin dev fs misc maj min local x mpt majmin dev fs misc maj min
if [[ $use_fstab != yes ]]; then if [[ $use_fstab != yes ]]; then
while read x x majmin x mpt x x fs misc; do while read x x majmin x mpt x x fs misc; do
[[ $fs = nfs ]] && { echo $dev; return 0;} [[ $fs = nfs ]] && { echo $dev; return 0;}
[[ $fs = nfs3 ]] && { echo $dev; return 0;} [[ $fs = nfs3 ]] && { echo $dev; return 0;}
[[ $fs = nfs4 ]] && { echo $dev; return 0;} [[ $fs = nfs4 ]] && { echo $dev; return 0;}
if [[ $mpt = $1 ]] && [[ ${majmin#0:} = $majmin ]]; then if [[ $mpt = $1 ]] && [[ ${majmin#0:} = $majmin ]]; then
echo $majmin; echo $majmin;
return 0 # we have a winner! return 0 # we have a winner!
fi fi
done < /proc/self/mountinfo done < /proc/self/mountinfo
fi fi
# fall back to /etc/fstab # fall back to /etc/fstab
while read dev mpt fs misc; do while read dev mpt fs misc; do
if [[ $mpt = $1 ]]; then if [[ $mpt = $1 ]]; then
[[ $fs = nfs ]] && { echo $dev; return 0;} [[ $fs = nfs ]] && { echo $dev; return 0;}
[[ $fs = nfs3 ]] && { echo $dev; return 0;} [[ $fs = nfs3 ]] && { echo $dev; return 0;}
[[ $fs = nfs4 ]] && { echo $dev; return 0;} [[ $fs = nfs4 ]] && { echo $dev; return 0;}
[[ $dev != ${dev#UUID=} ]] && dev=/dev/disk/by-uuid/${dev#UUID=} [[ $dev != ${dev#UUID=} ]] && dev=/dev/disk/by-uuid/${dev#UUID=}
[[ $dev != ${dev#LABEL=} ]] && dev=/dev/disk/by-label/${dev#LABEL=} [[ $dev != ${dev#LABEL=} ]] && dev=/dev/disk/by-label/${dev#LABEL=}
[[ -b $dev ]] || return 1 # oops, not a block device. [[ -b $dev ]] || return 1 # oops, not a block device.
ls -nLl "$dev" | { ls -nLl "$dev" | {
read x x x x maj min x; read x x x x maj min x;
maj=${maj//,/}; maj=${maj//,/};
echo $maj:$min; echo $maj:$min;
} && return 0 } && return 0
fi fi
done < /etc/fstab done < /etc/fstab
return 1; return 1;
} }
@ -169,12 +171,12 @@ check_block_and_slaves() {
"$1" $2 && return "$1" $2 && return
check_vol_slaves "$@" && return 0 check_vol_slaves "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]]; then if [[ -f /sys/dev/block/$2/../dev ]]; then
check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") && return 0 check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") && return 0
fi fi
[[ -d /sys/dev/block/$2/slaves ]] || return 1 [[ -d /sys/dev/block/$2/slaves ]] || return 1
for x in /sys/dev/block/$2/slaves/*/dev; do for x in /sys/dev/block/$2/slaves/*/dev; do
[[ -f $x ]] || continue [[ -f $x ]] || continue
check_block_and_slaves $1 $(cat "$x") && return 0 check_block_and_slaves $1 $(cat "$x") && return 0
done done
return 1 return 1
} }
@ -191,19 +193,19 @@ get_numeric_dev() {
# And the volume group might be bigger than the devices the LV needs. # And the volume group might be bigger than the devices the LV needs.
check_vol_slaves() { check_vol_slaves() {
for i in /dev/mapper/*; do for i in /dev/mapper/*; do
lv=$(get_numeric_dev $i) lv=$(get_numeric_dev $i)
if [[ $lv = $2 ]]; then if [[ $lv = $2 ]]; then
vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null) vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space # strip space
vg=$(echo $vg) vg=$(echo $vg)
if [[ $vg ]]; then if [[ $vg ]]; then
for pv in $(lvm vgs --noheadings -o pv_name "$vg" 2>/dev/null); \ for pv in $(lvm vgs --noheadings -o pv_name "$vg" 2>/dev/null); \
do do
check_block_and_slaves $1 $(get_numeric_dev $pv) \ check_block_and_slaves $1 $(get_numeric_dev $pv) \
&& return 0 && return 0
done done
fi fi
fi fi
done done
return 1 return 1
} }
@ -286,13 +288,13 @@ inst_library() {
local src=$1 dest=${2:-$1} lib reallib symlink local src=$1 dest=${2:-$1} lib reallib symlink
[[ -e $initdir$dest ]] && return 0 [[ -e $initdir$dest ]] && return 0
if [[ -L $src ]]; then if [[ -L $src ]]; then
reallib=$(readlink -f "$src") reallib=$(readlink -f "$src")
lib=${src##*/} lib=${src##*/}
inst_simple "$reallib" "$reallib" inst_simple "$reallib" "$reallib"
inst_dir "${dest%/*}" inst_dir "${dest%/*}"
(cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib") (cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib")
else else
inst_simple "$src" "$dest" inst_simple "$src" "$dest"
fi fi


# Create additional symlinks. See rev_symlinks description. # Create additional symlinks. See rev_symlinks description.
@ -310,7 +312,7 @@ find_binary() {
local binpath="/bin /sbin /usr/bin /usr/sbin" p local binpath="/bin /sbin /usr/bin /usr/sbin" p
[[ -z ${1##/*} && -x $1 ]] && { echo $1; return 0; } [[ -z ${1##/*} && -x $1 ]] && { echo $1; return 0; }
for p in $binpath; do for p in $binpath; do
[[ -x $p/$1 ]] && { echo "$p/$1"; return 0; } [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
done done
return 1 return 1
} }
@ -326,33 +328,33 @@ inst_binary() {
[[ -e $initdir$target ]] && return 0 [[ -e $initdir$target ]] && return 0
# I love bash! # I love bash!
LC_ALL=C ldd $bin 2>/dev/null | while read line; do LC_ALL=C ldd $bin 2>/dev/null | while read line; do
[[ $line = 'not a dynamic executable' ]] && return 1 [[ $line = 'not a dynamic executable' ]] && return 1
if [[ $line =~ not\ found ]]; then if [[ $line =~ not\ found ]]; then
derror "Missing a shared library required by $bin." derror "Missing a shared library required by $bin."
derror "Run \"ldd $bin\" to find out what it is." derror "Run \"ldd $bin\" to find out what it is."
derror "dracut cannot create an initrd." derror "dracut cannot create an initrd."
exit 1 exit 1
fi fi
so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)' so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
[[ $line =~ $so_regex ]] || continue [[ $line =~ $so_regex ]] || continue
FILE=${BASH_REMATCH[1]} FILE=${BASH_REMATCH[1]}
[[ -e ${initdir}$FILE ]] && continue [[ -e ${initdir}$FILE ]] && continue
# see if we are loading an optimized version of a shared lib. # see if we are loading an optimized version of a shared lib.
lib_regex='^(/lib[^/]*).*' lib_regex='^(/lib[^/]*).*'
if [[ $FILE =~ $lib_regex ]]; then if [[ $FILE =~ $lib_regex ]]; then
TLIBDIR=${BASH_REMATCH[1]} TLIBDIR=${BASH_REMATCH[1]}
BASE=${FILE##*/} BASE=${FILE##*/}
# prefer nosegneg libs, then unoptimized ones. # prefer nosegneg libs, then unoptimized ones.
for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do
[[ -e $f/$BASE ]] || continue [[ -e $f/$BASE ]] || continue
FILE=$f/$BASE FILE=$f/$BASE
break break
done done
inst_library "$FILE" "$TLIBDIR/$BASE" inst_library "$FILE" "$TLIBDIR/$BASE"
IF_dynamic=yes IF_dynamic=yes
continue continue
fi fi
inst_library "$FILE" inst_library "$FILE"
done done
inst_simple "$bin" "$target" inst_simple "$bin" "$target"
} }
@ -384,7 +386,7 @@ inst_symlink() {
find_rule() { find_rule() {
[[ -f $1 ]] && { echo "$1"; return 0; } [[ -f $1 ]] && { echo "$1"; return 0; }
for r in . /lib/udev/rules.d /etc/udev/rules.d $dracutbasedir/rules.d; do for r in . /lib/udev/rules.d /etc/udev/rules.d $dracutbasedir/rules.d; do
[[ -f $r/$1 ]] && { echo "$r/$1"; return 0; } [[ -f $r/$1 ]] && { echo "$r/$1"; return 0; }
done done
return 1 return 1
} }
@ -409,14 +411,14 @@ inst() {
case $# in case $# in
1) ;; 1) ;;
2) [[ ! $initdir && -d $2 ]] && export initdir=$2 2) [[ ! $initdir && -d $2 ]] && export initdir=$2
[[ $initdir = $2 ]] && set $1;; [[ $initdir = $2 ]] && set $1;;
3) [[ -z $initdir ]] && export initdir=$2 3) [[ -z $initdir ]] && export initdir=$2
set $1 $3;; set $1 $3;;
*) derror "inst only takes 1 or 2 or 3 arguments" *) derror "inst only takes 1 or 2 or 3 arguments"
exit 1;; exit 1;;
esac esac
for x in inst_symlink inst_script inst_binary inst_simple; do for x in inst_symlink inst_script inst_binary inst_simple; do
$x "$@" && return 0 $x "$@" && return 0
done done
return 1 return 1
} }
@ -426,31 +428,31 @@ inst() {
# All hooks should be POSIX/SuS compliant, they will be sourced by init. # All hooks should be POSIX/SuS compliant, they will be sourced by init.
inst_hook() { inst_hook() {
if ! [[ -f $3 ]]; then if ! [[ -f $3 ]]; then
derror "Cannot install a hook ($3) that does not exist." derror "Cannot install a hook ($3) that does not exist."
derror "Aborting initrd creation." derror "Aborting initrd creation."
exit 1 exit 1
elif ! strstr "$hookdirs" "$1"; then elif ! strstr "$hookdirs" "$1"; then
derror "No such hook type $1. Aborting initrd creation." derror "No such hook type $1. Aborting initrd creation."
exit 1 exit 1
fi fi
inst_simple "$3" "/${1}/${2}${3##*/}" inst_simple "$3" "/${1}/${2}${3##*/}"
} }


dracut_install() { dracut_install() {
if [[ $1 = '-o' ]]; then if [[ $1 = '-o' ]]; then
local optional=yes local optional=yes
shift shift
fi fi
while (($# > 0)); do while (($# > 0)); do
if ! inst "$1" ; then if ! inst "$1" ; then
if [[ $optional = yes ]]; then if [[ $optional = yes ]]; then
dwarning "Skipping program $1 as it cannot be found and is flagged to be optional" dwarning "Skipping program $1 as it cannot be found and is flagged to be optional"
else else
derror "Failed to install $1" derror "Failed to install $1"
exit 1 exit 1
fi fi
fi fi
shift shift
done done
} }


@ -511,15 +513,15 @@ check_module_deps() {
[[ -d $moddir && -x $moddir/install ]] || return 1 [[ -d $moddir && -x $moddir/install ]] || return 1
# if we do not have a check script, we are unconditionally included # if we do not have a check script, we are unconditionally included
if [[ -x $moddir/check ]]; then if [[ -x $moddir/check ]]; then
"$moddir/check" "$moddir/check"
ret=$? ret=$?
# a return value of 255 = load module only as a dependency. # a return value of 255 = load module only as a dependency.
((ret==0||ret==255)) || return 1 ((ret==0||ret==255)) || return 1
for dep in $("$moddir/check" -d); do for dep in $("$moddir/check" -d); do
check_module_deps "$dep" && continue check_module_deps "$dep" && continue
dwarning "Dependency $mod failed." dwarning "Dependency $mod failed."
return 1 return 1
done done
fi fi
mods_to_load+=" $1 " mods_to_load+=" $1 "
} }
@ -535,9 +537,9 @@ should_source_module() {
[[ -x $1/check ]] || return 0 [[ -x $1/check ]] || return 0
"$1/check" $hostonly || continue "$1/check" $hostonly || continue
for dep in $("$1/check" -d); do for dep in $("$1/check" -d); do
check_module_deps "$dep" && continue check_module_deps "$dep" && continue
dwarning "Cannot load dracut module \"$mod\", dependencies failed." dwarning "Cannot load dracut module \"$mod\", dependencies failed."
return 1 return 1
done done
} }


@ -545,33 +547,33 @@ check_modules() {
local modcheck; local modcheck;
local mod; local mod;
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
local mod=${moddir##*/}; mod=${mod#[0-9][0-9]} local mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
# If we are already scheduled to be loaded, no need to check again. # If we are already scheduled to be loaded, no need to check again.
strstr " $mods_to_load " " $mod " && continue strstr " $mods_to_load " " $mod " && continue
# This should never happen, but... # This should never happen, but...
[[ -d $moddir ]] || continue [[ -d $moddir ]] || continue
strstr " $omit_dracutmodules " " $mod " && continue strstr " $omit_dracutmodules " " $mod " && continue


if ! strstr " $dracutmodules $add_dracutmodules " " $mod "; then if ! strstr " $dracutmodules $add_dracutmodules " " $mod "; then
# module not in our list # module not in our list
if [[ $dracutmodules = all ]]; then if [[ $dracutmodules = all ]]; then
# check, if we can install this module # check, if we can install this module
should_source_module "$moddir" || continue should_source_module "$moddir" || continue
else else
# skip this module # skip this module
continue continue
fi fi
else else
if [ -x "$moddir/check" ] \ if [ -x "$moddir/check" ] \
&& "$moddir/check" -d > /dev/null 2>&1; then && "$moddir/check" -d > /dev/null 2>&1; then
check_module_deps "$mod" || { check_module_deps "$mod" || {
dwarning "Cannot load dracut module \"$mod\", dependencies failed." dwarning "Cannot load dracut module \"$mod\", dependencies failed."
continue continue
} }
fi fi
fi fi


mods_to_load+=" $mod " mods_to_load+=" $mod "
done done


modcheck=$add_dracutmodules modcheck=$add_dracutmodules
@ -589,18 +591,18 @@ install_kmod_with_fw() {
local modname=${1##*/} fwdir found local modname=${1##*/} fwdir found
modname=${modname%.ko*} modname=${modname%.ko*}
inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \ inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \
return 0 # no need to go further if the module is already installed return 0 # no need to go further if the module is already installed
for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
found='' found=''
for fwdir in $fw_dir; do for fwdir in $fw_dir; do
if [[ -d $fwdir && -f $fwdir/$fw ]]; then if [[ -d $fwdir && -f $fwdir/$fw ]]; then
inst_simple "$fwdir/$fw" "/lib/firmware/$fw" inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
found=yes found=yes
fi fi
done done
if [[ $found != yes ]]; then if [[ $found != yes ]]; then
dinfo "Possible missing firmware \"${fw}\" for kernel module \"${mod}.ko\"" dinfo "Possible missing firmware \"${fw}\" for kernel module \"${mod}.ko\""
fi fi
done done
} }


@ -614,9 +616,9 @@ for_each_kmod_dep() {
local func=$1 kmod=$2 cmd modpapth options local func=$1 kmod=$2 cmd modpapth options
shift 2 shift 2
modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | \ modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | \
while read cmd modpath options; do while read cmd modpath options; do
[[ $cmd = insmod ]] || continue [[ $cmd = insmod ]] || continue
$func $modpath $func $modpath
done done
} }


@ -630,16 +632,16 @@ for_each_kmod_dep() {
# This function returns the full filenames of modules that match $1 # This function returns the full filenames of modules that match $1
filter_kernel_modules () ( filter_kernel_modules () (
if ! [[ $hostonly ]]; then if ! [[ $hostonly ]]; then
filtercmd='find "$srcmods/kernel/drivers" -name "*.ko" -o -name "*.ko.gz"' filtercmd='find "$srcmods/kernel/drivers" -name "*.ko" -o -name "*.ko.gz"'
else else
filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename -k $kernel' filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename -k $kernel'
fi fi
for modname in $(eval $filtercmd); do for modname in $(eval $filtercmd); do
case $modname in case $modname in
*.ko) "$1" "$modname" && echo "$modname";; *.ko) "$1" "$modname" && echo "$modname";;
*.ko.gz) gzip -dc "$modname" > $initdir/$$.ko *.ko.gz) gzip -dc "$modname" > $initdir/$$.ko
$1 $initdir/$$.ko && echo "$modname" $1 $initdir/$$.ko && echo "$modname"
rm -f $initdir/$$.ko;; rm -f $initdir/$$.ko;;
esac esac
done done
) )
@ -649,46 +651,46 @@ instmods() {
[[ $no_kernel = yes ]] && return [[ $no_kernel = yes ]] && return
local mod mpargs modpath modname cmd moddirname local mod mpargs modpath modname cmd moddirname
while (($# > 0)); do while (($# > 0)); do
mod=${1%.ko*} mod=${1%.ko*}
case $mod in case $mod in
=*) # This introduces 2 incompatible meanings for =* arguments =*)
# This introduces 2 incompatible meanings for =* arguments
# to instmods. We need to decide which one to keep. # to instmods. We need to decide which one to keep.
if [[ $mod = =ata && -f $srcmods/modules.block ]] ; then if [[ $mod = =ata && -f $srcmods/modules.block ]] ; then
instmods $mpargs $(egrep 'ata|ahci' "${srcmods}/modules.block") instmods $mpargs $(egrep 'ata|ahci' "${srcmods}/modules.block")
elif [ -f $srcmods/modules.${mod#=} ]; then elif [ -f $srcmods/modules.${mod#=} ]; then
instmods $mpargs $(cat ${srcmods}/modules.${mod#=} ) instmods $mpargs $(cat ${srcmods}/modules.${mod#=} )
else else
instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*") instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*")
fi fi
;; ;;
--*) mod=${mod##*/} --*)
mpargs+=" $mod";; mod=${mod##*/}
mpargs+=" $mod";;
i2o_scsi) shift; continue;; # Do not load this diagnostic-only module i2o_scsi) shift; continue;; # Do not load this diagnostic-only module
*) mod=${mod##*/} *) mod=${mod##*/}
# if we are already installed, skip this module and go on # if we are already installed, skip this module and go on
# to the next one. # to the next one.
[[ -f $initdir/$1 ]] && { shift; continue; } [[ -f $initdir/$1 ]] && { shift; continue; }
# If we are building a host-specific initramfs and this # If we are building a host-specific initramfs and this
# module is not already loaded, move on to the next one. # module is not already loaded, move on to the next one.
[[ $hostonly ]] && ! grep -qe "\<${mod//-/_}\>" /proc/modules && \ [[ $hostonly ]] && ! grep -qe "\<${mod//-/_}\>" /proc/modules && \
! echo $add_drivers | grep -qe "\<${mod}\>" && { ! echo $add_drivers | grep -qe "\<${mod}\>" && {
shift; continue; shift; continue;
} }


# We use '-d' option in modprobe only if modules prefix path # We use '-d' option in modprobe only if modules prefix path
# differs from default '/'. This allows us to use Dracut with # differs from default '/'. This allows us to use Dracut with
# old version of modprobe which doesn't have '-d' option. # old version of modprobe which doesn't have '-d' option.
moddirname=${srcmods%%/lib/modules/*} moddirname=${srcmods%%/lib/modules/*}
[[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/" [[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/"


# ok, load the module, all its dependencies, and any firmware # ok, load the module, all its dependencies, and any firmware
# it may require # it may require
for_each_kmod_dep install_kmod_with_fw $mod \ for_each_kmod_dep install_kmod_with_fw $mod \
--set-version $kernel ${moddirname} --set-version $kernel ${moddirname}
;; ;;
esac esac
shift shift
done done
} }

# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/bash --norc #!/bin/bash --norc
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# Copyright 2005-2009 Red Hat, Inc. All rights reserved. # Copyright 2005-2009 Red Hat, Inc. All rights reserved.
# #
@ -43,13 +45,13 @@ function get_verbose() {




function get_numeric_dev() { function get_numeric_dev() {
( (
fmt="%d:%d" fmt="%d:%d"
if [ "$1" == "hex" ]; then if [ "$1" == "hex" ]; then
fmt="%x:%x" fmt="%x:%x"
fi fi
ls -lH "$2" | awk '{ sub(/,/, "", $5); printf("'"$fmt"'", $5, $6); }' ls -lH "$2" | awk '{ sub(/,/, "", $5); printf("'"$fmt"'", $5, $6); }'
) 2>/dev/null ) 2>/dev/null
} }




@ -173,7 +175,7 @@ finddevnoinsys() {
majmin="$1" majmin="$1"
if [ -n "$majmin" ]; then if [ -n "$majmin" ]; then
dev=$(for x in /sys/block/* ; do find $x/ -name dev ; done | while read device ; do \ dev=$(for x in /sys/block/* ; do find $x/ -name dev ; done | while read device ; do \
echo "$majmin" | cmp -s $device && echo $device ; done) echo "$majmin" | cmp -s $device && echo $device ; done)
if [ -n "$dev" ]; then if [ -n "$dev" ]; then
dev=${dev%%/dev} dev=${dev%%/dev}
dev=${dev%%/} dev=${dev%%/}
@ -309,7 +311,7 @@ iscsi_set_parameters() {
iscsi_get_rec_val $tmpfile "node.session.auth.password" iscsi_get_rec_val $tmpfile "node.session.auth.password"
chap_pw="-w ${result}" chap_pw="-w ${result}"
else else
chap="" chap=""
fi fi


iscsi_get_rec_val $tmpfile "node.session.auth.username_in" iscsi_get_rec_val $tmpfile "node.session.auth.username_in"
@ -319,7 +321,7 @@ iscsi_set_parameters() {
iscsi_get_rec_val $tmpfile "node.session.auth.password_in" iscsi_get_rec_val $tmpfile "node.session.auth.password_in"
chap_in_pw="-W ${result}" chap_in_pw="-W ${result}"
else else
chap_in="" chap_in=""
fi fi


rm $tmpfile rm $tmpfile
@ -395,29 +397,29 @@ handledm() {
done << EOF done << EOF
$(dmsetup table -j $major -m $minor 2>/dev/null) $(dmsetup table -j $major -m $minor 2>/dev/null)
EOF EOF
local name=$(dmsetup info --noheadings -c -j $major -m $minor -o name) local name=$(dmsetup info --noheadings -c -j $major -m $minor -o name)
local vg=$(lvshow "/dev/mapper/$name") local vg=$(lvshow "/dev/mapper/$name")
local raids=$(/sbin/dmraid -s -craidname 2>/dev/null | grep -vi "no raid disks") local raids=$(/sbin/dmraid -s -craidname 2>/dev/null | grep -vi "no raid disks")
if [ -n "$vg" ]; then if [ -n "$vg" ]; then
vg=`echo $vg` # strip whitespace vg=`echo $vg` # strip whitespace
case " $vg_list " in case " $vg_list " in
*" $vg "*) ;; *" $vg "*) ;;
*) vg_list="$vg_list $vg" *) vg_list="$vg_list $vg"
[ -z "$nolvm" ] && find_base_dm_mods [ -z "$nolvm" ] && find_base_dm_mods
;;
esac
fi
for raid in $raids ; do
if [ "$raid" == "$name" ]; then
case " $DMRAIDS " in
*" $raid "*) ;;
*) DMRAIDS="$DMRAIDS $raid"
[ -z "$nodmraid" ] && find_base_dm_mods
;; ;;
esac esac
break
fi fi
done for raid in $raids ; do
if [ "$raid" == "$name" ]; then
case " $DMRAIDS " in
*" $raid "*) ;;
*) DMRAIDS="$DMRAIDS $raid"
[ -z "$nodmraid" ] && find_base_dm_mods
;;
esac
break
fi
done
} }


handleiscsi() { handleiscsi() {
@ -440,25 +442,25 @@ handleraid() {
return 0 return 0
fi fi


levels=$(awk "/^$1[ ]*:/ { print\$4 }" /proc/mdstat) levels=$(awk "/^$1[ ]*:/ { print\$4 }" /proc/mdstat)


for level in $levels ; do for level in $levels ; do
case $level in case $level in
linear) linear)
start=1 start=1
;; ;;
multipath) multipath)
start=1 start=1
;; ;;
raid[01] | raid10) raid[01] | raid10)
start=1 start=1
;; ;;
raid[456]) raid[456])
start=1 start=1
;; ;;
*) *)
error "raid level $level (in /proc/mdstat) not recognized" error "raid level $level (in /proc/mdstat) not recognized"
;; ;;
esac esac
done done
if [ "$start" = 1 ]; then if [ "$start" = 1 ]; then
@ -474,7 +476,7 @@ lvshow() {


vgdisplay() { vgdisplay() {
lvm vgdisplay --ignorelockingfailure -v $1 2>/dev/null | lvm vgdisplay --ignorelockingfailure -v $1 2>/dev/null |
sed -n 's/PV Name//p' sed -n 's/PV Name//p'
} }


dmmods_found="n" dmmods_found="n"
@ -508,78 +510,78 @@ while [ $# -gt 0 ]; do
shift shift
fi fi
;; ;;
--rootdev*) --rootdev*)
if [ "$1" != "${1##--rootdev=}" ]; then if [ "$1" != "${1##--rootdev=}" ]; then
rootdev="${1##--rootdev=}" rootdev="${1##--rootdev=}"
else else
rootdev="$2" rootdev="$2"
shift shift
fi fi
;; ;;
--thawdev*) --thawdev*)
if [ "$1" != "${1##--thawdev=}" ]; then if [ "$1" != "${1##--thawdev=}" ]; then
thawdev="${1##--thawdev=}" thawdev="${1##--thawdev=}"
else else
thawdev="$2" thawdev="$2"
shift shift
fi fi
;; ;;
--rootfs*) --rootfs*)
if [ "$1" != "${1##--rootfs=}" ]; then if [ "$1" != "${1##--rootfs=}" ]; then
rootfs="${1##--rootfs=}" rootfs="${1##--rootfs=}"
else else
rootfs="$2" rootfs="$2"
shift shift
fi fi
;; ;;
--rootopts*) --rootopts*)
if [ "$1" != "${1##--rootopts=}" ]; then if [ "$1" != "${1##--rootopts=}" ]; then
rootopts="${1##--rootopts=}" rootopts="${1##--rootopts=}"
else else
rootopts="$2" rootopts="$2"
shift shift
fi fi
;; ;;
--root*) --root*)
if [ "$1" != "${1##--root=}" ]; then if [ "$1" != "${1##--root=}" ]; then
root="${1##--root=}" root="${1##--root=}"
else else
root="$2" root="$2"
shift shift
fi fi
;; ;;
--loopdev*) --loopdev*)
if [ "$1" != "${1##--loopdev=}" ]; then if [ "$1" != "${1##--loopdev=}" ]; then
loopdev="${1##--loopdev=}" loopdev="${1##--loopdev=}"
else else
loopdev="$2" loopdev="$2"
shift shift
fi fi
;; ;;
--loopfs*) --loopfs*)
if [ "$1" != "${1##--loopfs=}" ]; then if [ "$1" != "${1##--loopfs=}" ]; then
loopfs="${1##--loopfs=}" loopfs="${1##--loopfs=}"
else else
loopfs="$2" loopfs="$2"
shift shift
fi fi
;; ;;
--loopopts*) --loopopts*)
if [ "$1" != "${1##--loopopts=}" ]; then if [ "$1" != "${1##--loopopts=}" ]; then
loopopts="${1##--loopopts=}" loopopts="${1##--loopopts=}"
else else
loopopts="$2" loopopts="$2"
shift shift
fi fi
;; ;;
--looppath*) --looppath*)
if [ "$1" != "${1##--looppath=}" ]; then if [ "$1" != "${1##--looppath=}" ]; then
looppath="${1##--looppath=}" looppath="${1##--looppath=}"
else else
looppath="$2" looppath="$2"
shift shift
fi fi
;; ;;
--help) --help)
usage -n usage -n
;; ;;
@ -597,33 +599,33 @@ while [ $# -gt 0 ]; do
shift shift
done done


[ -z "$rootfs" ] && rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' $fstab) [ -z "$rootfs" ] && rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' $fstab)
[ -z "$rootopts" ] && rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' $fstab) [ -z "$rootopts" ] && rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' $fstab)
[ -z "$rootopts" ] && rootopts="defaults" [ -z "$rootopts" ] && rootopts="defaults"




[ -z "$rootdev" ] && rootdev=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $fstab) [ -z "$rootdev" ] && rootdev=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $fstab)
# check if it's nfsroot # check if it's nfsroot
physdev="" physdev=""
if [ "$rootfs" == "nfs" ]; then if [ "$rootfs" == "nfs" ]; then
if [ "x$net_list" == "x" ]; then if [ "x$net_list" == "x" ]; then
handlenfs $rootdev handlenfs $rootdev
fi
else
# check if it's root by label
rdev=$rootdev
rdev=$(resolve_device_name "$rdev")
rootopts=$(echo $rootopts | sed -e 's/^r[ow],//' -e 's/,_netdev//' -e 's/_netdev//' -e 's/,r[ow],$//' -e 's/,r[ow],/,/' -e 's/^r[ow]$/defaults/' -e 's/$/,ro/')
findstoragedriver "$rdev"
fi fi
else
# check if it's root by label
rdev=$rootdev
rdev=$(resolve_device_name "$rdev")
rootopts=$(echo $rootopts | sed -e 's/^r[ow],//' -e 's/,_netdev//' -e 's/_netdev//' -e 's/,r[ow],$//' -e 's/,r[ow],/,/' -e 's/^r[ow]$/defaults/' -e 's/$/,ro/')
findstoragedriver "$rdev"
fi


# find the first swap dev which would get used for swsusp # find the first swap dev which would get used for swsusp
[ -z "$thawdev" ] && thawdev=$(awk '/^[ \t]*[^#]/ { if ($3 == "swap") { print $1; exit }}' $fstab) [ -z "$thawdev" ] && thawdev=$(awk '/^[ \t]*[^#]/ { if ($3 == "swap") { print $1; exit }}' $fstab)
swsuspdev="$thawdev" swsuspdev="$thawdev"
if [ -n "$swsuspdev" ]; then if [ -n "$swsuspdev" ]; then
swsuspdev=$(resolve_device_name "$swsuspdev") swsuspdev=$(resolve_device_name "$swsuspdev")
findstoragedriver "$swsuspdev" findstoragedriver "$swsuspdev"
fi fi




cemit() cemit()
@ -678,7 +680,7 @@ fi


if [ -z "$nolvm" -a -n "$vg_list" ]; then if [ -z "$nolvm" -a -n "$vg_list" ]; then
for vg in $vg_list; do for vg in $vg_list; do
echo -n "rd_LVM_VG=$vg " echo -n "rd_LVM_VG=$vg "
done done
else else
echo -n "rd_NO_LVM " echo -n "rd_NO_LVM "
@ -712,4 +714,3 @@ if [ -n "$rootdev" ]; then
fi fi


echo echo
# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


STATEDIR=/var/lib/dracut STATEDIR=/var/lib/dracut
BOOTDIR=/boot BOOTDIR=/boot
@ -11,23 +13,23 @@ version=""
set -e set -e


if $USETRIGGERS \ if $USETRIGGERS \
&& [ x"$DPKG_MAINTSCRIPT_PACKAGE" != x ] \ && [ x"$DPKG_MAINTSCRIPT_PACKAGE" != x ] \
&& [ $# = 1 ] \ && [ $# = 1 ] \
&& [ x"$1" = x-u ] \ && [ x"$1" = x-u ] \
&& dpkg-trigger --check-supported 2>/dev/null && dpkg-trigger --check-supported 2>/dev/null
then then
if dpkg-trigger --no-await update-initramfs; then if dpkg-trigger --no-await update-initramfs; then
echo "dracut-update-initramfs: deferring update (trigger activated)" echo "dracut-update-initramfs: deferring update (trigger activated)"
exit 0 exit 0
fi fi
fi fi


usage() usage()
{ {
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
printf "${@}\n\n" >&2 printf "${@}\n\n" >&2
fi fi
cat >&2 << EOF cat >&2 << EOF
Usage: ${0} [OPTION]... Usage: ${0} [OPTION]...


Options: Options:
@ -41,422 +43,422 @@ Options:
-h This message -h This message


EOF EOF
exit 1 exit 1
} }


# chroot check # chroot check
chrooted() chrooted()
{ {
# borrowed from udev's postinst # borrowed from udev's postinst
if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
# the devicenumber/inode pair of / is the same as that of # the devicenumber/inode pair of / is the same as that of
# /sbin/init's root, so we're *not* in a chroot and hence # /sbin/init's root, so we're *not* in a chroot and hence
# return false. # return false.
return 1 return 1
fi fi
return 0 return 0
} }


mild_panic() mild_panic()
{ {
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
printf "${@}\n" >&2 printf "${@}\n" >&2
fi fi
exit 0 exit 0
} }


panic() panic()
{ {
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
printf "${@}\n" >&2 printf "${@}\n" >&2
fi fi
exit 1 exit 1
} }


verbose() verbose()
{ {
if [ "${verbose}" = 1 ]; then if [ "${verbose}" = 1 ]; then
printf "${@}\n" printf "${@}\n"
fi fi
} }


version_exists() version_exists()
{ {
[ -e "${STATEDIR}/${1}" ] && [ -e "${initramfs}" ] [ -e "${STATEDIR}/${1}" ] && [ -e "${initramfs}" ]
return $? return $?
} }


set_initramfs() set_initramfs()
{ {
initramfs="${BOOTDIR}/dracut.img-${version}" initramfs="${BOOTDIR}/dracut.img-${version}"
} }




# backup initramfs while running # backup initramfs while running
backup_initramfs() backup_initramfs()
{ {
[ ! -r "${initramfs}" ] && return 0 [ ! -r "${initramfs}" ] && return 0
initramfs_bak="${initramfs}.dpkg-bak" initramfs_bak="${initramfs}.dpkg-bak"
[ -r "${initramfs_bak}" ] && rm -f "${initramfs_bak}" [ -r "${initramfs_bak}" ] && rm -f "${initramfs_bak}"
ln -f "${initramfs}" "${initramfs_bak}" \ ln -f "${initramfs}" "${initramfs_bak}" \
|| cp -a "${initramfs}" "${initramfs_bak}" || cp -a "${initramfs}" "${initramfs_bak}"
verbose "Keeping ${initramfs_bak}" verbose "Keeping ${initramfs_bak}"
} }


# keep booted initramfs # keep booted initramfs
backup_booted_initramfs() backup_booted_initramfs()
{ {
initramfs_bak="${initramfs}.dpkg-bak" initramfs_bak="${initramfs}.dpkg-bak"


# first time run thus no backup # first time run thus no backup
[ ! -r "${initramfs_bak}" ] && return 0 [ ! -r "${initramfs_bak}" ] && return 0


# chroot with no /proc # chroot with no /proc
[ ! -r /proc/uptime ] && rm -f "${initramfs_bak}" && return 0 [ ! -r /proc/uptime ] && rm -f "${initramfs_bak}" && return 0


# no kept backup wanted # no kept backup wanted
[ "${backup_initramfs}" = "no" ] && rm -f "${initramfs_bak}" && return 0 [ "${backup_initramfs}" = "no" ] && rm -f "${initramfs_bak}" && return 0


# no backup yet # no backup yet
if [ ! -r "${initramfs}.bak" ]; then if [ ! -r "${initramfs}.bak" ]; then
mv -f ${initramfs_bak} "${initramfs}.bak" mv -f ${initramfs_bak} "${initramfs}.bak"
verbose "Backup ${initramfs}.bak" verbose "Backup ${initramfs}.bak"
return 0 return 0
fi fi


# keep booted initramfs # keep booted initramfs
uptime_days=$(awk '{printf "%d", $1 / 3600 / 24}' /proc/uptime) uptime_days=$(awk '{printf "%d", $1 / 3600 / 24}' /proc/uptime)
if [ -n "$uptime_days" ]; then if [ -n "$uptime_days" ]; then
boot_initramfs=$(find "${initramfs}.bak" -mtime +${uptime_days}) boot_initramfs=$(find "${initramfs}.bak" -mtime +${uptime_days})
fi fi
if [ -n "${boot_initramfs}" ]; then if [ -n "${boot_initramfs}" ]; then
mv -f "${initramfs_bak}" "${initramfs}.bak" mv -f "${initramfs_bak}" "${initramfs}.bak"
verbose "Backup ${initramfs}.bak" verbose "Backup ${initramfs}.bak"
return 0 return 0
fi fi
verbose "Removing current backup ${initramfs_bak}" verbose "Removing current backup ${initramfs_bak}"
rm -f ${initramfs_bak} rm -f ${initramfs_bak}
} }


# nuke generated copy # nuke generated copy
remove_initramfs() remove_initramfs()
{ {
[ -z "${initramfs_bak}" ] && return 0 [ -z "${initramfs_bak}" ] && return 0
rm -f "${initramfs_bak}" rm -f "${initramfs_bak}"
verbose "Removing ${initramfs_bak}" verbose "Removing ${initramfs_bak}"
} }




generate_initramfs() generate_initramfs()
{ {
echo "dracut-update-initramfs: Generating ${initramfs}" echo "dracut-update-initramfs: Generating ${initramfs}"
OPTS="" OPTS=""
if [ "${verbose}" = 1 ]; then if [ "${verbose}" = 1 ]; then
OPTS="-v ${OPTS}" OPTS="-v ${OPTS}"
fi fi
##WORK HERE! ##WORK HERE!
if dracut ${OPTS} "${initramfs}.new" "${version}"; then if dracut ${OPTS} "${initramfs}.new" "${version}"; then
mv -f "${initramfs}.new" "${initramfs}" mv -f "${initramfs}.new" "${initramfs}"
set_sha1 set_sha1
else else
mkinitramfs_return="$?" mkinitramfs_return="$?"
remove_initramfs remove_initramfs
rm -f "${initramfs}.new" rm -f "${initramfs}.new"
if [ "$mkinitramfs_return" = "2" ]; then if [ "$mkinitramfs_return" = "2" ]; then
# minversion wasn't met, exit 0 # minversion wasn't met, exit 0
exit 0 exit 0
fi fi
echo "update-initramfs: failed for ${initramfs}" echo "update-initramfs: failed for ${initramfs}"
exit $mkinitramfs_return exit $mkinitramfs_return
fi fi
} }


# lilo call # lilo call
run_lilo() run_lilo()
{ {
# show lilo errors on failure # show lilo errors on failure
if ! lilo -t > /dev/null 2>&1 ; then if ! lilo -t > /dev/null 2>&1 ; then
echo "ERROR lilo fails for new ${initramfs}:" echo "ERROR lilo fails for new ${initramfs}:"
echo echo
lilo -t lilo -t
fi fi
lilo lilo
} }


# check if lilo is on mbr # check if lilo is on mbr
mbr_check() mbr_check()
{ {
# try to discover grub|grub2 and be happy # try to discover grub|grub2 and be happy
[ -r /boot/grub/grub.cfg ] \ [ -r /boot/grub/grub.cfg ] \
&& groot=$(awk '/^set root=/{print substr($2, 7, 3); exit}' \ && groot=$(awk '/^set root=/{print substr($2, 7, 3); exit}' \
/boot/grub/grub.cfg) /boot/grub/grub.cfg)
[ -r /boot/grub/menu.lst ] \ [ -r /boot/grub/menu.lst ] \
&& groot=$(awk '/^root/{print substr($2, 2, 3); exit}' \ && groot=$(awk '/^root/{print substr($2, 2, 3); exit}' \
/boot/grub/menu.lst) /boot/grub/menu.lst)
[ -e /boot/grub/device.map ] && [ -n "${groot}" ] \ [ -e /boot/grub/device.map ] && [ -n "${groot}" ] \
&& dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map) && dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map)
[ -n "${dev}" ] && [ -r ${dev} ] \ [ -n "${dev}" ] && [ -r ${dev} ] \
&& dd if="${dev}" bs=512 skip=0 count=1 2> /dev/null \ && dd if="${dev}" bs=512 skip=0 count=1 2> /dev/null \
| grep -q GRUB && return 0 | grep -q GRUB && return 0


# check out lilo.conf for validity # check out lilo.conf for validity
boot=$(awk -F = '/^boot=/{ print $2}' /etc/lilo.conf) boot=$(awk -F = '/^boot=/{ print $2}' /etc/lilo.conf)
[ -z "${boot}" ] && return 0 [ -z "${boot}" ] && return 0
case ${boot} in case ${boot} in
/dev/md/*) /dev/md/*)
if [ -r /proc/mdstat ]; then if [ -r /proc/mdstat ]; then
MD=${boot#/dev/md/} MD=${boot#/dev/md/}
boot="/dev/$(awk "/^md${MD}/{print substr(\$5, 1, 3)}" \ boot="/dev/$(awk "/^md${MD}/{print substr(\$5, 1, 3)}" \
/proc/mdstat)" /proc/mdstat)"
fi fi
;; ;;
/dev/md*) /dev/md*)
if [ -r /proc/mdstat ]; then if [ -r /proc/mdstat ]; then
MD=${boot#/dev/} MD=${boot#/dev/}
boot="/dev/$(awk "/^${MD}/{print substr(\$5, 1, 3)}" \ boot="/dev/$(awk "/^${MD}/{print substr(\$5, 1, 3)}" \
/proc/mdstat)" /proc/mdstat)"
fi fi
;; ;;
esac esac
[ ! -r "${boot}" ] && return 0 [ ! -r "${boot}" ] && return 0
dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO \ dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO \
&& run_lilo && return 0 && run_lilo && return 0


# no idea which bootloader is used # no idea which bootloader is used
echo echo
echo "WARNING: grub and lilo installed." echo "WARNING: grub and lilo installed."
echo "If you use grub as bootloader everything is fine." echo "If you use grub as bootloader everything is fine."
echo "If you use lilo as bootloader you must run lilo!" echo "If you use lilo as bootloader you must run lilo!"
echo echo
} }


# Invoke bootloader # Invoke bootloader
run_bootloader() run_bootloader()
{ {
# if both lilo and grub around, figure out if lilo needs to be run # if both lilo and grub around, figure out if lilo needs to be run
if ( command -v update-grub >/dev/null 2>&1 \ if ( command -v update-grub >/dev/null 2>&1 \
|| [ -e /boot/grub/menu.lst ] || [ -e /boot/grub/grub.cfg ] ) \ || [ -e /boot/grub/menu.lst ] || [ -e /boot/grub/grub.cfg ] ) \
&& ( [ -e /etc/lilo.conf ] && command -v lilo >/dev/null 2>&1 ); then && ( [ -e /etc/lilo.conf ] && command -v lilo >/dev/null 2>&1 ); then
[ -r "${KPKGCONF}" ] && \ [ -r "${KPKGCONF}" ] && \
do_b=$(awk '/^do_bootloader/{print $3}' "${KPKGCONF}") do_b=$(awk '/^do_bootloader/{print $3}' "${KPKGCONF}")
if [ "${do_b}" = "yes" ] || [ "${do_b}" = "Yes" ] \ if [ "${do_b}" = "yes" ] || [ "${do_b}" = "Yes" ] \
|| [ "${do_b}" = "YES" ]; then || [ "${do_b}" = "YES" ]; then
run_lilo run_lilo
return 0 return 0
elif [ "${do_b}" = "no" ] || [ "${do_b}" = "No" ] \ elif [ "${do_b}" = "no" ] || [ "${do_b}" = "No" ] \
|| [ "${do_b}" = "NO" ]; then || [ "${do_b}" = "NO" ]; then
return 0 return 0
fi fi


# do_bootloader unconfigured # do_bootloader unconfigured
mbr_check mbr_check
return 0 return 0
fi fi
if [ -r /etc/lilo.conf ] && command -v lilo >/dev/null 2>&1; then if [ -r /etc/lilo.conf ] && command -v lilo >/dev/null 2>&1; then
run_lilo run_lilo
return 0 return 0
fi fi
if command -v elilo >/dev/null 2>&1; then if command -v elilo >/dev/null 2>&1; then
elilo elilo
return 0 return 0
fi fi
if [ -r /etc/zipl.conf ]; then if [ -r /etc/zipl.conf ]; then
zipl zipl
fi fi
if flash-kernel --supported >/dev/null 2>&1; then if flash-kernel --supported >/dev/null 2>&1; then
flash-kernel ${version} flash-kernel ${version}
fi fi
} }


compare_sha1() compare_sha1()
{ {
sha1sum "${initramfs}" | diff "${STATEDIR}/${version}" - >/dev/null 2>&1 sha1sum "${initramfs}" | diff "${STATEDIR}/${version}" - >/dev/null 2>&1
return $? return $?
} }


# Note that this must overwrite so that updates work. # Note that this must overwrite so that updates work.
set_sha1() set_sha1()
{ {
sha1sum "${initramfs}" > "${STATEDIR}/${version}" sha1sum "${initramfs}" > "${STATEDIR}/${version}"
} }


delete_sha1() delete_sha1()
{ {
rm -f "${STATEDIR}/${version}" rm -f "${STATEDIR}/${version}"
} }


# ro /boot is not modified # ro /boot is not modified
ro_boot_check() ro_boot_check()
{ {
# check irrelevant inside of a chroot # check irrelevant inside of a chroot
if [ ! -r /proc/mounts ] || chrooted; then if [ ! -r /proc/mounts ] || chrooted; then
return 0 return 0
fi fi


boot_opts=$(awk '/boot/{if ((match($4, /^ro/) || match($4, /,ro/)) \ boot_opts=$(awk '/boot/{if ((match($4, /^ro/) || match($4, /,ro/)) \
&& $2 == "/boot") print "ro"}' /proc/mounts) && $2 == "/boot") print "ro"}' /proc/mounts)
if [ -n "${boot_opts}" ]; then if [ -n "${boot_opts}" ]; then
echo "WARNING: /boot is ro mounted." echo "WARNING: /boot is ro mounted."
echo "update-initramfs: Not updating ${initramfs}" echo "update-initramfs: Not updating ${initramfs}"
exit 0 exit 0
fi fi
} }


get_sorted_versions() get_sorted_versions()
{ {
version_list="" version_list=""


for gsv_x in "${STATEDIR}"/*; do for gsv_x in "${STATEDIR}"/*; do
gsv_x="$(basename "${gsv_x}")" gsv_x="$(basename "${gsv_x}")"
if [ "${gsv_x}" = '*' ]; then if [ "${gsv_x}" = '*' ]; then
return 0 return 0
fi fi
worklist="" worklist=""
for gsv_i in $version_list; do for gsv_i in $version_list; do
if dpkg --compare-versions "${gsv_x}" '>' "${gsv_i}"; then if dpkg --compare-versions "${gsv_x}" '>' "${gsv_i}"; then
worklist="${worklist} ${gsv_x} ${gsv_i}" worklist="${worklist} ${gsv_x} ${gsv_i}"
gsv_x="" gsv_x=""
else else
worklist="${worklist} ${gsv_i}" worklist="${worklist} ${gsv_i}"
fi fi
done done
if [ "${gsv_x}" != "" ]; then if [ "${gsv_x}" != "" ]; then
worklist="${worklist} ${gsv_x}" worklist="${worklist} ${gsv_x}"
fi fi
version_list="${worklist}" version_list="${worklist}"
done done


verbose "Available versions: ${version_list}" verbose "Available versions: ${version_list}"
} }


set_current_version() set_current_version()
{ {
if [ -f /boot/dracut.img-`uname -r` ]; then if [ -f /boot/dracut.img-`uname -r` ]; then
version=`uname -r` version=`uname -r`
fi fi
} }


set_linked_version() set_linked_version()
{ {
if [ -e /initrd.img ] && [ -L /initrd.img ]; then if [ -e /initrd.img ] && [ -L /initrd.img ]; then
linktarget="$(basename "$(readlink /initrd.img)")" linktarget="$(basename "$(readlink /initrd.img)")"
fi fi


if [ -e /boot/initrd.img ] && [ -L /boot/initrd.img ]; then if [ -e /boot/initrd.img ] && [ -L /boot/initrd.img ]; then
linktarget="$(basename "$(readlink /boot/initrd.img)")" linktarget="$(basename "$(readlink /boot/initrd.img)")"
fi fi


if [ -z "${linktarget}" ]; then if [ -z "${linktarget}" ]; then
return return
fi fi


version="${linktarget##*img-}" version="${linktarget##*img-}"
} }


set_highest_version() set_highest_version()
{ {
get_sorted_versions get_sorted_versions
set -- ${version_list} set -- ${version_list}
version=${1} version=${1}
} }


create() create()
{ {
if [ -z "${version}" ]; then if [ -z "${version}" ]; then
usage "Create mode requires a version argument" usage "Create mode requires a version argument"
fi fi


set_initramfs set_initramfs


if [ "${takeover}" = 0 ]; then if [ "${takeover}" = 0 ]; then
if version_exists "${version}"; then if version_exists "${version}"; then
panic "Cannot create version ${version}: already exists" panic "Cannot create version ${version}: already exists"
fi fi


if [ -e "${initramfs}" ]; then if [ -e "${initramfs}" ]; then
panic "${initramfs} already exists, cannot create." panic "${initramfs} already exists, cannot create."
fi fi
fi fi


generate_initramfs generate_initramfs
} }


update() update()
{ {
if [ "${update_initramfs}" = "no" ]; then if [ "${update_initramfs}" = "no" ]; then
echo "update-initramfs: Not updating initramfs." echo "update-initramfs: Not updating initramfs."
exit 0 exit 0
fi fi


if [ -z "${version}" ]; then if [ -z "${version}" ]; then
set_highest_version set_highest_version
fi fi


if [ -z "${version}" ]; then if [ -z "${version}" ]; then
set_linked_version set_linked_version
fi fi


if [ -z "${version}" ]; then if [ -z "${version}" ]; then
set_current_version set_current_version
fi fi


if [ -z "${version}" ]; then if [ -z "${version}" ]; then
verbose "Nothing to do, exiting." verbose "Nothing to do, exiting."
exit 0 exit 0
fi fi


set_initramfs set_initramfs


ro_boot_check ro_boot_check


altered_check altered_check


backup_initramfs backup_initramfs


generate_initramfs generate_initramfs


run_bootloader run_bootloader


backup_booted_initramfs backup_booted_initramfs
} }


delete() delete()
{ {
if [ -z "${version}" ]; then if [ -z "${version}" ]; then
usage "Delete mode requires a version argument" usage "Delete mode requires a version argument"
fi fi


set_initramfs set_initramfs


if [ ! -e "${initramfs}" ]; then if [ ! -e "${initramfs}" ]; then
panic "Cannot delete ${initramfs}, doesn't exist." panic "Cannot delete ${initramfs}, doesn't exist."
fi fi


if ! version_exists "${version}"; then if ! version_exists "${version}"; then
panic "Cannot delete version ${version}: Not created by this utility." panic "Cannot delete version ${version}: Not created by this utility."
fi fi


altered_check altered_check


echo "update-initramfs: Deleting ${initramfs}" echo "update-initramfs: Deleting ${initramfs}"


delete_sha1 delete_sha1


rm -f "${initramfs}" rm -f "${initramfs}"
} }


# Check for update mode on existing and modified initramfs # Check for update mode on existing and modified initramfs
altered_check() altered_check()
{ {
# No check on takeover # No check on takeover
[ "${takeover}" = 1 ] && return 0 [ "${takeover}" = 1 ] && return 0
if [ ! -e "${initramfs}" ]; then if [ ! -e "${initramfs}" ]; then
mild_panic "${initramfs} does not exist. Cannot update." mild_panic "${initramfs} does not exist. Cannot update."
fi fi
if ! compare_sha1; then if ! compare_sha1; then
echo "update-initramfs: ${initramfs} has been altered." >&2 echo "update-initramfs: ${initramfs} has been altered." >&2
mild_panic "update-initramfs: Cannot update. Override with -t option." mild_panic "update-initramfs: Cannot update. Override with -t option."
fi fi
} }


# Defaults # Defaults
@ -468,91 +470,91 @@ takeover=0
## ##


while getopts "k:cudyvtb:h?" flag; do while getopts "k:cudyvtb:h?" flag; do
case "${flag}" in case "${flag}" in
k) k)
version="${OPTARG}" version="${OPTARG}"
;; ;;
c) c)
mode="c" mode="c"
;; ;;
d) d)
mode="d" mode="d"
;; ;;
u) u)
mode="u" mode="u"
;; ;;
v) v)
verbose="1" verbose="1"
;; ;;
y) y)
yes="1" yes="1"
;; ;;
t) t)
takeover="1" takeover="1"
;; ;;
b) b)
BOOTDIR="${OPTARG}" BOOTDIR="${OPTARG}"
if [ ! -d "${BOOTDIR}" ]; then if [ ! -d "${BOOTDIR}" ]; then
echo "Error: ${BOOTDIR} is not a directory." echo "Error: ${BOOTDIR} is not a directory."
exit 1 exit 1
fi fi
;; ;;
h|?) h|?)
usage usage
;; ;;
esac esac
done done


shift $((${OPTIND} - 1)) shift $((${OPTIND} - 1))


if [ $# -ne 0 ]; then if [ $# -ne 0 ]; then
echo "Invalid argument for option -k." echo "Invalid argument for option -k."
usage usage
fi fi


# Validate arguments # Validate arguments
if [ -z "${mode}" ]; then if [ -z "${mode}" ]; then
usage "You must specify at least one of -c, -u, or -d." usage "You must specify at least one of -c, -u, or -d."
fi fi


if [ "${version}" = "all" ] \ if [ "${version}" = "all" ] \
|| ( [ "${update_initramfs}" = "all" ] && [ -z "${version}" ] ); then || ( [ "${update_initramfs}" = "all" ] && [ -z "${version}" ] ); then
: FIXME check for --yes, and if not ask are you sure : FIXME check for --yes, and if not ask are you sure
get_sorted_versions get_sorted_versions
if [ -z "${version_list}" ]; then if [ -z "${version_list}" ]; then
verbose "Nothing to do, exiting." verbose "Nothing to do, exiting."
exit 0 exit 0
fi fi


OPTS="-b ${BOOTDIR}" OPTS="-b ${BOOTDIR}"
if [ "${verbose}" = "1" ]; then if [ "${verbose}" = "1" ]; then
OPTS="${OPTS} -v" OPTS="${OPTS} -v"
fi fi
if [ "${takeover}" = "1" ]; then if [ "${takeover}" = "1" ]; then
OPTS="${OPTS} -t" OPTS="${OPTS} -t"
fi fi
if [ "${yes}" = "1" ]; then if [ "${yes}" = "1" ]; then
OPTS="${OPTS} -y" OPTS="${OPTS} -y"
fi fi
for u_version in ${version_list}; do for u_version in ${version_list}; do
# Don't stop if one version doesn't work. # Don't stop if one version doesn't work.
set +e set +e
verbose "Execute: ${0} -${mode} -k \"${u_version}\" ${OPTS}" verbose "Execute: ${0} -${mode} -k \"${u_version}\" ${OPTS}"
"${0}" -${mode} -k "${u_version}" ${OPTS} "${0}" -${mode} -k "${u_version}" ${OPTS}
set -e set -e
done done
exit 0 exit 0
fi fi




case "${mode}" in case "${mode}" in
c) c)
create create
;; ;;
d) d)
delete delete
;; ;;
u) u)
update update
;; ;;
esac esac

View File

@ -1,4 +1,23 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# Copyright 2005-2010 Harald Hoyer <harald@redhat.com>
# Copyright 2005-2010 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#


[[ $# -eq 1 ]] || { echo "Usage: $(basename $0) <initramfs file>" ; exit 1 ; } [[ $# -eq 1 ]] || { echo "Usage: $(basename $0) <initramfs file>" ; exit 1 ; }
[[ -f $1 ]] || { echo "$1 does not exist" ; exit 1 ; } [[ -f $1 ]] || { echo "$1 does not exist" ; exit 1 ; }

View File

@ -98,5 +98,3 @@ if [[ $basicmodules ]]; then
else else
dracut $dracut_args "$target" "$kernel" dracut $dracut_args "$target" "$kernel"
fi fi

# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -x /sbin/bootchartd ] || exit 1 [ -x /sbin/bootchartd ] || exit 1


# do not enable bootchartd by default # do not enable bootchartd by default

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


inst /sbin/bootchartd inst /sbin/bootchartd
inst /bin/bash inst /bin/bash

View File

@ -1,2 +1,4 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -x /bin/dash ] [ -x /bin/dash ]

View File

@ -1,4 +1,7 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

# If another shell is already installed, do not use dash # If another shell is already installed, do not use dash
[[ -x $initdir/bin/sh ]] && return [[ -x $initdir/bin/sh ]] && return



View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


[[ $1 = -d ]] && exit 0 [[ $1 = -d ]] && exit 0
exit 255 exit 255

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
do_fips() do_fips()
{ {
FIPSMODULES=$(cat /etc/fipsmodules) FIPSMODULES=$(cat /etc/fipsmodules)
@ -6,21 +8,21 @@ do_fips()
KERNEL=$(uname -r) KERNEL=$(uname -r)
udevadm trigger --action=add >/dev/null 2>&1 udevadm trigger --action=add >/dev/null 2>&1
case "$boot" in case "$boot" in
block:LABEL=*|LABEL=*) block:LABEL=*|LABEL=*)
boot="${boot#block:}" boot="${boot#block:}"
boot="$(echo $boot | sed 's,/,\\x2f,g')" boot="$(echo $boot | sed 's,/,\\x2f,g')"
boot="/dev/disk/by-label/${boot#LABEL=}" boot="/dev/disk/by-label/${boot#LABEL=}"
bootok=1 ;; bootok=1 ;;
block:UUID=*|UUID=*) block:UUID=*|UUID=*)
boot="${boot#block:}" boot="${boot#block:}"
boot="/dev/disk/by-uuid/${root#UUID=}" boot="/dev/disk/by-uuid/${root#UUID=}"
bootok=1 ;; bootok=1 ;;
/dev/*) /dev/*)
bootok=1 ;; bootok=1 ;;
esac esac


[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version) [ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)

if [ $UDEVVERSION -ge 143 ]; then if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=$boot udevadm settle --exit-if-exists=$boot
else else
@ -66,5 +68,3 @@ else
do_fips || die "FIPS integrity test failed" do_fips || die "FIPS integrity test failed"
set +e set +e
fi fi

# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


inst_hook pre-trigger 01 "$moddir/fips.sh" inst_hook pre-trigger 01 "$moddir/fips.sh"
dracut_install sha512hmac rmmod insmod mount uname umount dracut_install sha512hmac rmmod insmod mount uname umount
@ -6,10 +8,8 @@ dracut_install sha512hmac rmmod insmod mount uname umount
for dir in "$usrlibdir" "$libdir"; do for dir in "$usrlibdir" "$libdir"; do
[[ -e $dir/libsoftokn3.so ]] && \ [[ -e $dir/libsoftokn3.so ]] && \
dracut_install $dir/libsoftokn3.so $dir/libsoftokn3.chk \ dracut_install $dir/libsoftokn3.so $dir/libsoftokn3.chk \
$dir/libfreebl3.so $dir/libfreebl3.chk && \ $dir/libfreebl3.so $dir/libfreebl3.chk && \
break break
done done


dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac

# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


FIPSMODULES="aead aes_generic aes-x86_64 ansi_cprng cbc ccm chainiv ctr" FIPSMODULES="aead aes_generic aes-x86_64 ansi_cprng cbc ccm chainiv ctr"
FIPSMODULES="$FIPSMODULES des deflate ecb eseqiv hmac seqiv sha256 sha512" FIPSMODULES="$FIPSMODULES des deflate ecb eseqiv hmac seqiv sha256 sha512"
@ -12,5 +14,3 @@ for mod in $FIPSMODULES; do
echo "blacklist $mod" >> "${initdir}/etc/modprobe.d/fips.conf" echo "blacklist $mod" >> "${initdir}/etc/modprobe.d/fips.conf"
fi fi
done done

# vim:ts=8:sw=4:sts=4:et

View File

@ -1,3 +1,5 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


exit 0 exit 0

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


[ -e /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n [ -e /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
[ -e /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard [ -e /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
@ -58,7 +60,7 @@ dev_open() {
local dev=$1 local dev=$1


exec 6<${dev} && \ exec 6<${dev} && \
exec 7>>${dev} exec 7>>${dev}
} }





View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps
DEFAULT_SYSFONT=LatArCyrHeb-16 DEFAULT_SYSFONT=LatArCyrHeb-16
@ -10,7 +12,7 @@ KEYBOARD_CONF="${initdir}/etc/sysconfig/keyboard"
findkeymap () { findkeymap () {
local MAP=$1 local MAP=$1
[[ ! -f $MAP ]] && \ [[ ! -f $MAP ]] && \
MAP=$(find ${kbddir}/keymaps -type f -name $MAP -o -name $MAP.\* | head -n1) MAP=$(find ${kbddir}/keymaps -type f -name $MAP -o -name $MAP.\* | head -n1)
[[ " $KEYMAPS " = *" $MAP "* ]] && return [[ " $KEYMAPS " = *" $MAP "* ]] && return
KEYMAPS="$KEYMAPS $MAP" KEYMAPS="$KEYMAPS $MAP"
case $MAP in case $MAP in
@ -161,12 +163,12 @@ checks() {
for kbddir in ${kbddir} /usr/lib/kbd /lib/kbd /usr/share for kbddir in ${kbddir} /usr/lib/kbd /lib/kbd /usr/share
do do
[[ -d "${kbddir}" ]] && \ [[ -d "${kbddir}" ]] && \
for dir in ${KBDSUBDIRS//,/ } for dir in ${KBDSUBDIRS//,/ }
do do
[[ -d "${kbddir}/${dir}" ]] && continue [[ -d "${kbddir}/${dir}" ]] && continue
false false
done && break done && break
kbddir='' kbddir=''
done done


[[ ${kbddir} ]] || { [[ ${kbddir} ]] || {

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


inst_key_val() { inst_key_val() {
local value local value

View File

@ -1,3 +1,5 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -f /etc/redhat-release ] [ -f /etc/redhat-release ]



View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if [ -e "$moddir/dracut-version" ]; then if [ -e "$moddir/dracut-version" ]; then
dracut_rpm_version=$(cat "$moddir/dracut-version") dracut_rpm_version=$(cat "$moddir/dracut-version")

View File

@ -1,3 +1,5 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
for i in dracut-*; do for i in dracut-*; do
if [ -f $i ]; then if [ -f $i ]; then
vinfo < $i vinfo < $i

View File

@ -1,22 +1,24 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if [[ $1 = -d ]]; then if [[ $1 = -d ]]; then
[ -d /etc/sysconfig/network-scripts/ ] && echo ifcfg [ -d /etc/sysconfig/network-scripts/ ] && echo ifcfg
exit 0 exit 0
fi fi


. $dracutfunctions . $dracutfunctions


for program in ip arping; do for program in ip arping; do
if ! type -P $program >/dev/null; then if ! type -P $program >/dev/null; then
dwarning "Could not find program \"$program\" required by network." dwarning "Could not find program \"$program\" required by network."
exit 1 exit 1
fi fi
done done
for program in dhclient brctl; do for program in dhclient brctl; do
if ! type -P $program >/dev/null; then if ! type -P $program >/dev/null; then
dwarning "Could not find program \"$program\" it might be required by network." dwarning "Could not find program \"$program\" it might be required by network."
fi fi
done done


exit 255 exit 255

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


setup_interface() { setup_interface() {
ip=$new_ip_address ip=$new_ip_address
@ -20,12 +22,12 @@ setup_interface() {
# disallow MTUs from 576 and below by default, so that broken # disallow MTUs from 576 and below by default, so that broken
# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc). # MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then
echo "if ! ip link set $netif mtu $mtu ; then" echo "if ! ip link set $netif mtu $mtu ; then"
echo "ip link set $netif down" echo "ip link set $netif down"
echo "ip link set $netif mtu $mtu" echo "ip link set $netif mtu $mtu"
echo "ip link set $netif up" echo "ip link set $netif up"
echo wait_for_if_up $netif echo wait_for_if_up $netif
echo "fi" echo "fi"
fi > /tmp/net.$netif.up fi > /tmp/net.$netif.up


echo ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif >> /tmp/net.$netif.up echo ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif >> /tmp/net.$netif.up
@ -34,9 +36,9 @@ setup_interface() {


[ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf [ -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 for s in $namesrv; do
echo nameserver $s echo nameserver $s
done done
fi >> /tmp/net.$netif.resolv.conf fi >> /tmp/net.$netif.resolv.conf


[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
@ -56,24 +58,24 @@ netif=$interface


case $reason in case $reason in
PREINIT) PREINIT)
echo "dhcp: PREINIT $netif up" echo "dhcp: PREINIT $netif up"
ip link set $netif up ip link set $netif up
wait_for_if_up $netif wait_for_if_up $netif
;; ;;
BOUND) BOUND)
echo "dhcp: BOND setting $netif" echo "dhcp: BOND setting $netif"
if ! arping -q -D -c 2 -I $netif $new_ip_address ; then if ! arping -q -D -c 2 -I $netif $new_ip_address ; then
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying" warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
exit 1 exit 1
fi fi
setup_interface setup_interface
set | while read line; do set | while read line; do
[ "${line#new_}" = "$line" ] && continue [ "${line#new_}" = "$line" ] && continue
echo "$line" echo "$line"
done >/tmp/dhclient.$netif.dhcpopts done >/tmp/dhclient.$netif.dhcpopts
echo online > /sys/class/net/$netif/uevent echo online > /sys/class/net/$netif/uevent
/sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif /sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif
;; ;;
*) echo "dhcp: $reason";; *) echo "dhcp: $reason";;
esac esac



View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# Don't continue if root is ok # Don't continue if root is ok
[ -n "$rootok" ] && return [ -n "$rootok" ] && return
@ -14,7 +16,7 @@ if [ "$root" = "dhcp" ] || [ "$root" = "dhcp6" ] || [ "$netroot" = "dhcp" ] ; th
# Done, all good! # Done, all good!
rootok=1 rootok=1
if [ "$netroot" != "dhcp" ] ; then if [ "$netroot" != "dhcp" ] ; then
netroot=$root netroot=$root
fi fi


# Shut up init error check # Shut up init error check

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# if there are no ifname parameters, just use NAME=KERNEL # if there are no ifname parameters, just use NAME=KERNEL
if ! getarg ifname= >/dev/null ; then if ! getarg ifname= >/dev/null ; then
@ -8,12 +10,12 @@ fi
{ {
for p in $(getargs ifname=); do for p in $(getargs ifname=); do
parse_ifname_opts $p parse_ifname_opts $p
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if" printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
done done


# Rename non named interfaces out of the way for named ones. # Rename non named interfaces out of the way for named ones.
for p in $(getargs ifname=); do for p in $(getargs ifname=); do
parse_ifname_opts $p parse_ifname_opts $p
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{type}=="1", NAME!="?*", KERNEL=="%s", NAME="%%k-renamed"\n' "$ifname_if" printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{type}=="1", NAME!="?*", KERNEL=="%s", NAME="%%k-renamed"\n' "$ifname_if"
done done
} > /etc/udev/rules.d/50-ifname.rules } > /etc/udev/rules.d/50-ifname.rules

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# We don't need to check for ip= errors here, that is handled by the # We don't need to check for ip= errors here, that is handled by the
# cmdline parser script # cmdline parser script
@ -14,16 +16,16 @@ do_dhcp() {
# XXX add -V vendor class and option parsing per kernel # XXX add -V vendor class and option parsing per kernel
echo "Starting dhcp for interface $netif" echo "Starting dhcp for interface $netif"
dhclient "$@" -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif \ dhclient "$@" -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif \
|| echo "dhcp failed" || echo "dhcp failed"
} }


load_ipv6() { load_ipv6() {
modprobe ipv6 modprobe ipv6
i=0 i=0
while [ ! -d /proc/sys/net/ipv6 ]; do while [ ! -d /proc/sys/net/ipv6 ]; do
i=$(($i+1)) i=$(($i+1))
[ $i -gt 10 ] && break [ $i -gt 10 ] && break
sleep 0.1 sleep 0.1
done done
} }


@ -33,17 +35,17 @@ do_ipv6auto() {
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
echo ip link set $netif up echo ip link set $netif up
echo wait_for_if_up $netif echo wait_for_if_up $netif
} > /tmp/net.$netif.up } > /tmp/net.$netif.up


[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname


namesrv=$(getargs nameserver) namesrv=$(getargs nameserver)
if [ -n "$namesrv" ] ; then if [ -n "$namesrv" ] ; then
for s in $namesrv; do for s in $namesrv; do
echo nameserver $s echo nameserver $s
done done
fi >> /tmp/net.$netif.resolv.conf fi >> /tmp/net.$netif.resolv.conf




@ -56,12 +58,12 @@ do_static() {
strstr $ip '*:*:*' && load_ipv6 strstr $ip '*:*:*' && load_ipv6


{ {
echo ip link set $netif up echo ip link set $netif up
echo wait_for_if_up $netif echo wait_for_if_up $netif
# do not flush addr for ipv6 # do not flush addr for ipv6
strstr $ip '*:*:*' || \ strstr $ip '*:*:*' || \
echo ip addr flush dev $netif echo ip addr flush dev $netif
echo ip addr add $ip/$mask dev $netif echo ip addr add $ip/$mask dev $netif
} > /tmp/net.$netif.up } > /tmp/net.$netif.up


[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
@ -69,9 +71,9 @@ do_static() {


namesrv=$(getargs nameserver) namesrv=$(getargs nameserver)
if [ -n "$namesrv" ] ; then if [ -n "$namesrv" ] ; then
for s in $namesrv; do for s in $namesrv; do
echo nameserver $s echo nameserver $s
done done
fi >> /tmp/net.$netif.resolv.conf fi >> /tmp/net.$netif.resolv.conf


echo online > /sys/class/net/$netif/uevent echo online > /sys/class/net/$netif/uevent
@ -130,9 +132,9 @@ ip=$(getarg ip)


if [ -z "$ip" ]; then if [ -z "$ip" ]; then
if [ "$netroot" = "dhcp6" ]; then if [ "$netroot" = "dhcp6" ]; then
do_dhcp -6 do_dhcp -6
else else
do_dhcp -4 do_dhcp -4
fi fi
fi fi


@ -140,24 +142,24 @@ fi
# looking for ip= lines # looking for ip= lines
for p in $(getargs ip=); do for p in $(getargs ip=); do
ip_to_var $p ip_to_var $p
# If this option isn't directed at our interface, skip it # If this option isn't directed at our interface, skip it
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue [ -n "$dev" ] && [ "$dev" != "$netif" ] && continue


# Store config for later use # Store config for later use
for i in ip srv gw mask hostname; do for i in ip srv gw mask hostname; do
eval '[ "$'$i'" ] && echo '$i'="$'$i'"' eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
done > /tmp/net.$netif.override done > /tmp/net.$netif.override


case $autoconf in case $autoconf in
dhcp|on|any) dhcp|on|any)
do_dhcp -4 ;; do_dhcp -4 ;;
dhcp6) dhcp6)
do_dhcp -6 ;; do_dhcp -6 ;;
auto6) auto6)
do_ipv6auto ;; do_ipv6auto ;;
*) *)
do_static ;; do_static ;;
esac esac
break break
done done

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
dracut_install ip dhclient brctl arping dracut_install ip dhclient brctl arping
inst "$moddir/ifup" "/sbin/ifup" inst "$moddir/ifup" "/sbin/ifup"
inst "$moddir/netroot" "/sbin/netroot" inst "$moddir/netroot" "/sbin/netroot"
@ -15,7 +17,7 @@ inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
arch=$(uname -m) arch=$(uname -m)


for dir in "$usrlibdir/tls/$arch" "$usrlibdir/tls" "$usrlibdir/$arch" \ for dir in "$usrlibdir/tls/$arch" "$usrlibdir/tls" "$usrlibdir/$arch" \
"$usrlibdir" "$libdir"; do "$usrlibdir" "$libdir"; do
for i in "$dir"/libnss_dns.so.* "$dir"/libnss_mdns4_minimal.so.*; do for i in "$dir"/libnss_dns.so.* "$dir"/libnss_mdns4_minimal.so.*; do
[ -e "$i" ] && dracut_install "$i" [ -e "$i" ] && dracut_install "$i"
done done

View File

@ -1,16 +1,19 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

# Include wired net drivers, excluding wireless # Include wired net drivers, excluding wireless


net_module_test() { net_module_test() {
local net_drivers='eth_type_trans|register_virtio_device' local net_drivers='eth_type_trans|register_virtio_device'
local unwanted_drivers='/(wireless|isdn|uwb)/' local unwanted_drivers='/(wireless|isdn|uwb)/'
egrep -q $net_drivers "$1" && \ egrep -q $net_drivers "$1" && \
egrep -qv 'iw_handler_get_spy' "$1" && \ egrep -qv 'iw_handler_get_spy' "$1" && \
[[ ! $1 =~ $unwanted_drivers ]] [[ ! $1 =~ $unwanted_drivers ]]
} }


instmods $(filter_kernel_modules net_module_test) instmods $(filter_kernel_modules net_module_test)

instmods ecb arc4 instmods ecb arc4
# bridge modules # bridge modules
instmods bridge stp llc instmods bridge stp llc

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


for f in /tmp/dhclient.*.pid; do for f in /tmp/dhclient.*.pid; do
[ -e $f ] || continue [ -e $f ] || continue

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# pxelinux provides macaddr '-' separated, but we need ':' # pxelinux provides macaddr '-' separated, but we need ':'
fix_bootif() { fix_bootif() {
@ -25,18 +27,18 @@ fix_bootif() {
# BOOTIF says everything, use only that one # BOOTIF says everything, use only that one
BOOTIF=$(getarg 'BOOTIF=') BOOTIF=$(getarg 'BOOTIF=')
if [ -n "$BOOTIF" ] ; then if [ -n "$BOOTIF" ] ; then
BOOTIF=$(fix_bootif "$BOOTIF") BOOTIF=$(fix_bootif "$BOOTIF")
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF" printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"


# If we have to handle multiple interfaces, handle only them. # If we have to handle multiple interfaces, handle only them.
elif [ -n "$IFACES" ] ; then elif [ -n "$IFACES" ] ; then
for iface in $IFACES ; do for iface in $IFACES ; do
printf 'ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface" printf 'ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
done done


# Default: We don't know the interface to use, handle all # Default: We don't know the interface to use, handle all
else else
printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n' printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
fi fi


} > /etc/udev/rules.d/60-net.rules } > /etc/udev/rules.d/60-net.rules

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


PATH=$PATH:/sbin:/usr/sbin PATH=$PATH:/sbin:/usr/sbin


@ -41,16 +43,16 @@ if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
# If we have a specific bootdev with no dhcpoptions or empty root-path, # If we have a specific bootdev with no dhcpoptions or empty root-path,
# we die. Otherwise we just warn # 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'" [ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available" warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
exit 1 exit 1
fi fi


# Set netroot to new_root_path, so cmdline parsers don't call # Set netroot to new_root_path, so cmdline parsers don't call
netroot=$new_root_path netroot=$new_root_path


for f in ./cmdline/90*.sh; do for f in ./cmdline/90*.sh; do
[ -f "$f" ] && . "$f"; [ -f "$f" ] && . "$f";
done done
else else
rootok="1" rootok="1"
@ -93,7 +95,7 @@ if [ -z "$dest" ] ; then
dummy=${netroot#*:} dummy=${netroot#*:}
dummy=${dummy%%:*} dummy=${dummy%%:*}
case "$dummy" in case "$dummy" in
[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) dest=$dummy;; [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) dest=$dummy;;
esac esac
fi fi
if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
@ -108,8 +110,8 @@ source_all netroot
if $handler $netif $netroot $NEWROOT; then if $handler $netif $netroot $NEWROOT; then
# Network rootfs mount successful # Network rootfs mount successful
for iface in $IFACES ; do for iface in $IFACES ; do
[ -f /tmp/dhclient.$iface.lease ] && cp /tmp/dhclient.$iface.lease /tmp/net.$iface.lease [ -f /tmp/dhclient.$iface.lease ] && cp /tmp/dhclient.$iface.lease /tmp/net.$iface.lease
[ -f /tmp/dhclient.$iface.dhcpopts ] && cp /tmp/dhclient.$iface.dhcpopts /tmp/net.$iface.dhcpopts [ -f /tmp/dhclient.$iface.dhcpopts ] && cp /tmp/dhclient.$iface.dhcpopts /tmp/net.$iface.dhcpopts
done done


# Save used netif for later use # Save used netif for later use
@ -119,9 +121,9 @@ else
# If we're trying with multiple interfaces, put that one down. # If we're trying with multiple interfaces, put that one down.
# ip down/flush ensures that routeing info goes away as well # ip down/flush ensures that routeing info goes away as well
if [ -z "$BOOTDEV" ] ; then if [ -z "$BOOTDEV" ] ; then
ip link set $netif down ip link set $netif down
ip addr flush dev $netif ip addr flush dev $netif
echo "#empty" > /etc/resolv.conf echo "#empty" > /etc/resolv.conf
fi fi
fi fi
exit 0 exit 0

View File

@ -1,9 +1,11 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# Format: # Format:
# bridge=<bridgename>:<ethname> # bridge=<bridgename>:<ethname>
# #
# bridge without parameters assumes bridge=br0:eth0 # bridge without parameters assumes bridge=br0:eth0
# #


# return if bridge already parsed # return if bridge already parsed
@ -12,7 +14,7 @@
# Check if bridge parameter is valid # Check if bridge parameter is valid
if getarg bridge= >/dev/null ; then if getarg bridge= >/dev/null ; then
if [ -z "$netroot" ] ; then if [ -z "$netroot" ] ; then
die "No netboot configured, bridge is invalid" die "No netboot configured, bridge is invalid"
fi fi
fi fi


@ -26,10 +28,10 @@ parsebridge() {


unset bridgename ethname unset bridgename ethname
case $# in case $# in
0) bridgename=br0; ethname=eth0 ;; 0) bridgename=br0; ethname=eth0 ;;
1) die "bridge= requires two parameters" ;; 1) die "bridge= requires two parameters" ;;
2) bridgename=$1; ethname=$2 ;; 2) bridgename=$1; ethname=$2 ;;
*) die "bridge= requires two parameters" ;; *) die "bridge= requires two parameters" ;;
esac esac
} }



View File

@ -1,7 +1,9 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# Format: # Format:
# ifname=<interface>:<mac> # ifname=<interface>:<mac>
# #
# Note letters in the macaddress must be lowercase! # Note letters in the macaddress must be lowercase!
# #

View File

@ -1,11 +1,13 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# Format: # Format:
# ip=[dhcp|on|any] # ip=[dhcp|on|any]
# #
# ip=<interface>:[dhcp|on|any] # ip=<interface>:[dhcp|on|any]
# #
# ip=<client-IP-number>:<server-id>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off] # ip=<client-IP-number>:<server-id>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
# #
# When supplying more than only ip= line, <interface> is mandatory and # When supplying more than only ip= line, <interface> is mandatory and
# bootdev= must contain the name of the primary interface to use for # bootdev= must contain the name of the primary interface to use for
@ -17,8 +19,8 @@
# Check if ip= lines should be used # Check if ip= lines should be used
if getarg ip= >/dev/null ; then if getarg ip= >/dev/null ; then
if [ -z "$netroot" ] ; then if [ -z "$netroot" ] ; then
echo "Warning: No netboot configured, ignoring ip= lines" echo "Warning: No netboot configured, ignoring ip= lines"
return; return;
fi fi
fi fi


@ -38,7 +40,7 @@ fi
if [ -z "$NEEDBOOTDEV" ] ; then if [ -z "$NEEDBOOTDEV" ] ; then
local count=0 local count=0
for p in $(getargs ip=); do for p in $(getargs ip=); do
count=$(( $count + 1 )) count=$(( $count + 1 ))
done done
[ $count -gt 1 ] && NEEDBOOTDEV=1 [ $count -gt 1 ] && NEEDBOOTDEV=1
fi fi
@ -59,39 +61,39 @@ for p in $(getargs ip=); do


# Empty autoconf defaults to 'dhcp' # Empty autoconf defaults to 'dhcp'
if [ -z "$autoconf" ] ; then if [ -z "$autoconf" ] ; then
warn "Empty autoconf values default to dhcp" warn "Empty autoconf values default to dhcp"
autoconf="dhcp" autoconf="dhcp"
fi fi


# Error checking for autoconf in combination with other values # Error checking for autoconf in combination with other values
case $autoconf in case $autoconf in
error) die "Error parsing option 'ip=$p'";; error) die "Error parsing option 'ip=$p'";;
bootp|rarp|both) die "Sorry, ip=$autoconf is currenty unsupported";; bootp|rarp|both) die "Sorry, ip=$autoconf is currenty unsupported";;
none|off) \ none|off) \
[ -z "$ip" ] && \ [ -z "$ip" ] && \
die "For argument 'ip=$p'\nValue '$autoconf' without static configuration does not make sense" die "For argument 'ip=$p'\nValue '$autoconf' without static configuration does not make sense"
[ -z "$mask" ] && \ [ -z "$mask" ] && \
die "Sorry, automatic calculation of netmask is not yet supported" die "Sorry, automatic calculation of netmask is not yet supported"
;; ;;
auto6);; auto6);;
dhcp|dhcp6|on|any) \ dhcp|dhcp6|on|any) \
[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \ [ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
die "Sorry, 'ip=$p' does not make sense for multiple interface configurations" die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
[ -n "$ip" ] && \ [ -n "$ip" ] && \
die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoconf'" die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoconf'"
;; ;;
*) die "For argument 'ip=$p'\nSorry, unknown value '$autoconf'";; *) die "For argument 'ip=$p'\nSorry, unknown value '$autoconf'";;
esac esac


if [ -n "$dev" ] ; then if [ -n "$dev" ] ; then
# We don't like duplicate device configs # We don't like duplicate device configs
if [ -n "$IFACES" ] ; then if [ -n "$IFACES" ] ; then
for i in $IFACES ; do for i in $IFACES ; do
[ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'" [ "$dev" = "$i" ] && die "For argument 'ip=$p'\nDuplication configurations for '$dev'"
done done
fi fi
# IFACES list for later use # IFACES list for later use
IFACES="$IFACES $dev" IFACES="$IFACES $dev"
fi fi


# Small optimization for udev rules # Small optimization for udev rules
@ -99,15 +101,15 @@ for p in $(getargs ip=); do


# Do we need to check for specific options? # 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) # Correct device? (Empty is ok as well)
[ "$dev" = "$BOOTDEV" ] || continue [ "$dev" = "$BOOTDEV" ] || continue
# Server-ip is there? # Server-ip is there?
[ -n "$DHCPORSERVER" ] && [ -n "$srv" ] && continue [ -n "$DHCPORSERVER" ] && [ -n "$srv" ] && continue
# dhcp? (It's simpler to check for a set ip. Checks above ensure that if # dhcp? (It's simpler to check for a set ip. Checks above ensure that if
# ip is there, we're static # ip is there, we're static
[ -z "$ip" ] && continue [ -z "$ip" ] && continue
# Not good! # Not good!
die "Server-ip or dhcp for netboot needed, but current arguments say otherwise" die "Server-ip or dhcp for netboot needed, but current arguments say otherwise"
fi fi


done done

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# ifcfg is required by network # ifcfg is required by network
#[[ $1 = -d ]] && echo network #[[ $1 = -d ]] && echo network

View File

@ -1,2 +1,4 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh" inst_hook pre-pivot 85 "$moddir/write-ifcfg.sh"

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# NFS root might have reached here before /tmp/net.ifaces was written # NFS root might have reached here before /tmp/net.ifaces was written
udevadm settle --timeout=30 udevadm settle --timeout=30
@ -16,40 +18,40 @@ for netif in $IFACES ; do
fi fi
cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
{ {
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=$netif" echo "DEVICE=$netif"
echo "ONBOOT=yes" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
if [ -f /tmp/net.$netif.lease ]; then if [ -f /tmp/net.$netif.lease ]; then
strstr "$ip" '*:*:*' && strstr "$ip" '*:*:*' &&
echo "DHCPV6C=yes" echo "DHCPV6C=yes"
echo "BOOTPROTO=dhcp" echo "BOOTPROTO=dhcp"
else else
echo "BOOTPROTO=none" echo "BOOTPROTO=none"
# If we've booted with static ip= lines, the override file is there # If we've booted with static ip= lines, the override file is there
. /tmp/net.$netif.override . /tmp/net.$netif.override
echo "IPADDR=$ip" echo "IPADDR=$ip"
echo "NETMASK=$mask" echo "NETMASK=$mask"
[ -n "$gw" ] && echo "GATEWAY=$gw" [ -n "$gw" ] && echo "GATEWAY=$gw"
fi fi
} > /tmp/ifcfg/ifcfg-$netif } > /tmp/ifcfg/ifcfg-$netif


# bridge needs different things written to ifcfg # bridge needs different things written to ifcfg
if [ -z "$bridge" ]; then if [ -z "$bridge" ]; then
# standard interface # standard interface
{ {
echo "HWADDR=$(cat /sys/class/net/$netif/address)" echo "HWADDR=$(cat /sys/class/net/$netif/address)"
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "NAME=\"Boot Disk\"" echo "NAME=\"Boot Disk\""
} >> /tmp/ifcfg/ifcfg-$netif } >> /tmp/ifcfg/ifcfg-$netif
else else
# bridge # bridge
{ {
echo "TYPE=Bridge" echo "TYPE=Bridge"
echo "NAME=\"Boot Disk\"" echo "NAME=\"Boot Disk\""
} >> /tmp/ifcfg/ifcfg-$netif } >> /tmp/ifcfg/ifcfg-$netif
# write separate ifcfg file for the raw eth interface # write separate ifcfg file for the raw eth interface
{ {
echo "DEVICE=$ethname" echo "DEVICE=$ethname"
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "ONBOOT=yes" echo "ONBOOT=yes"
@ -57,7 +59,7 @@ for netif in $IFACES ; do
echo "HWADDR=$(cat /sys/class/net/$ethname/address)" echo "HWADDR=$(cat /sys/class/net/$ethname/address)"
echo "BRIDGE=$netif" echo "BRIDGE=$netif"
echo "NAME=$ethname" echo "NAME=$ethname"
} >> /tmp/ifcfg/ifcfg-$ethname } >> /tmp/ifcfg/ifcfg-$ethname
fi fi
done done



View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# TODO: splash_geninitramfs # TODO: splash_geninitramfs
# TODO: /usr/share/splashutils/initrd.splash # TODO: /usr/share/splashutils/initrd.splash

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


CDROOT=0 CDROOT=0
. /lib/gensplash-lib.sh . /lib/gensplash-lib.sh

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


CDROOT=0 CDROOT=0
. /lib/gensplash-lib.sh . /lib/gensplash-lib.sh

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if ! getarg rd_NO_SPLASH; then if ! getarg rd_NO_SPLASH; then
[ -c /dev/null ] || mknod /dev/null c 1 3 [ -c /dev/null ] || mknod /dev/null c 1 3

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


call_splash_geninitramfs() { call_splash_geninitramfs() {
local out ret local out ret

View File

@ -1,3 +1,5 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[[ $1 = -d ]] && type -P cryptsetup >/dev/null && echo crypt [[ $1 = -d ]] && type -P cryptsetup >/dev/null && echo crypt
[[ -x /sbin/plymouthd && -x /bin/plymouth && -x /usr/sbin/plymouth-set-default-theme ]] [[ -x /sbin/plymouthd && -x /bin/plymouth && -x /usr/sbin/plymouth-set-default-theme ]]

View File

@ -1,8 +1,10 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if grep -q nash /usr/libexec/plymouth/plymouth-populate-initrd \ if grep -q nash /usr/libexec/plymouth/plymouth-populate-initrd \
|| ! grep -q PLYMOUTH_POPULATE_SOURCE_FUNCTIONS /usr/libexec/plymouth/plymouth-populate-initrd \ || ! grep -q PLYMOUTH_POPULATE_SOURCE_FUNCTIONS /usr/libexec/plymouth/plymouth-populate-initrd \
|| [ ! -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then || [ ! -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
. "$moddir"/plymouth-populate-initrd . "$moddir"/plymouth-populate-initrd
else else
PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$dracutfunctions" \ PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$dracutfunctions" \

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# Include KMS capable drm drivers # Include KMS capable drm drivers
for modname in $(find "$srcmods/kernel/drivers/gpu/drm" -name '*.ko' 2>/dev/null); do for modname in $(find "$srcmods/kernel/drivers/gpu/drm" -name '*.ko' 2>/dev/null); do
grep -q drm_crtc_init $modname && instmods $modname grep -q drm_crtc_init $modname && instmods $modname

View File

@ -1 +1,3 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -x /bin/plymouth ] && /bin/plymouth --hide-splash [ -x /bin/plymouth ] && /bin/plymouth --hide-splash

View File

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if [ -x /bin/plymouth ]; then if [ -x /bin/plymouth ]; then
/bin/plymouth --newroot=$NEWROOT /bin/plymouth --newroot=$NEWROOT
fi fi

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png" PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png"
PLYMOUTH_THEME=$(plymouth-set-default-theme) PLYMOUTH_THEME=$(plymouth-set-default-theme)


@ -11,28 +13,28 @@ mkdir -p "${initdir}/usr/share/plymouth"


if [[ $hostonly ]]; then if [[ $hostonly ]]; then
dracut_install "${usrlibdir}/plymouth/text.so" \ dracut_install "${usrlibdir}/plymouth/text.so" \
"${usrlibdir}/plymouth/details.so" \ "${usrlibdir}/plymouth/details.so" \
"/usr/share/plymouth/themes/details/details.plymouth" \ "/usr/share/plymouth/themes/details/details.plymouth" \
"/usr/share/plymouth/themes/text/text.plymouth" \ "/usr/share/plymouth/themes/text/text.plymouth" \


if [[ -d /usr/share/plymouth/themes/${PLYMOUTH_THEME} ]]; then if [[ -d /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 "$x" ]] || break [[ -f "$x" ]] || break
inst $x inst $x
done done
fi fi


if [ -L /usr/share/plymouth/themes/default.plymouth ]; then if [ -L /usr/share/plymouth/themes/default.plymouth ]; then
inst /usr/share/plymouth/themes/default.plymouth inst /usr/share/plymouth/themes/default.plymouth
# Install plugin for this theme # Install plugin for this theme
PLYMOUTH_PLUGIN=$(grep "^ModuleName=" /usr/share/plymouth/themes/default.plymouth | while read a b c; do echo $b; done;) PLYMOUTH_PLUGIN=$(grep "^ModuleName=" /usr/share/plymouth/themes/default.plymouth | while read a b c; do echo $b; done;)
inst "${usrlibdir}/plymouth/${PLYMOUTH_PLUGIN}.so" inst "${usrlibdir}/plymouth/${PLYMOUTH_PLUGIN}.so"
fi fi
else else
for x in /usr/share/plymouth/themes/{text,details}/* ; do for x in /usr/share/plymouth/themes/{text,details}/* ; do
[[ -f "$x" ]] || continue [[ -f "$x" ]] || continue
THEME_DIR=$(dirname "$x") THEME_DIR=$(dirname "$x")
mkdir -p "${initdir}/$THEME_DIR" mkdir -p "${initdir}/$THEME_DIR"
dracut_install "$x" dracut_install "$x"
done done
for x in "${usrlibdir}"/plymouth/{text,details}.so ; do for x in "${usrlibdir}"/plymouth/{text,details}.so ; do
@ -41,9 +43,7 @@ else
dracut_install "$x" dracut_install "$x"
done done
( (
cd ${initdir}/usr/share/plymouth/themes; cd ${initdir}/usr/share/plymouth/themes;
ln -s text/text.plymouth default.plymouth 2>&1; ln -s text/text.plymouth default.plymouth 2>&1;
) )
fi fi

# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if ! getarg rd_NO_PLYMOUTH; then if ! getarg rd_NO_PLYMOUTH; then
[ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3 [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
@ -19,6 +21,3 @@ if ! getarg rd_NO_PLYMOUTH; then
/lib/udev/console_init tty0 /lib/udev/console_init tty0
/bin/plymouth --show-splash 2>&1 | vinfo /bin/plymouth --show-splash 2>&1 | vinfo
fi fi


# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# No Xen-detect? Boo!! # No Xen-detect? Boo!!
if ! hash xen-detect 2>/dev/null; then if ! hash xen-detect 2>/dev/null; then

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
hash xen-detect 2>/dev/null || \ hash xen-detect 2>/dev/null || \
hash -p /usr/lib/xen-default/bin/xen-detect xen-detect hash -p /usr/lib/xen-default/bin/xen-detect xen-detect
inst "$(hash -t xen-detect)" /sbin/xen-detect inst "$(hash -t xen-detect)" /sbin/xen-detect

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


for i in \ for i in \
xenbus_probe_frontend xen-pcifront \ xenbus_probe_frontend xen-pcifront \

View File

@ -1,10 +1,12 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
xen-detect xen-detect
RC=$? RC=$?
if [ "$RC" = "1" ] ; then if [ "$RC" = "1" ] ; then
modprobe xenbus_probe_frontend modprobe xenbus_probe_frontend
modprobe xen-kbdfront modprobe xen-kbdfront
modprobe xen-fbfront modprobe xen-fbfront
modprobe xen-blkfront modprobe xen-blkfront
modprobe xen-netfront modprobe xen-netfront
modprobe xen-pcifront modprobe xen-pcifront
fi fi

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# We depend on udev-rules being loaded # We depend on udev-rules being loaded
[[ "$1" = "-d" ]] && exit 0 [[ "$1" = "-d" ]] && exit 0
@ -15,7 +17,7 @@ is_btrfs() { get_fs_type /dev/block/$1 |grep -q btrfs; }
if [[ "$1" = "-h" ]]; then if [[ "$1" = "-h" ]]; then
rootdev=$(find_root_block_device) rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then if [[ $rootdev ]]; then
is_btrfs "$rootdev" || exit 1 is_btrfs "$rootdev" || exit 1
fi fi
fi fi



View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


inst_rules "$moddir/40-btrfs.rules" inst_rules "$moddir/40-btrfs.rules"
dracut_install btrfsctl dracut_install btrfsctl

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# if cryptsetup is not installed, then we cannot support encrypted devices. # if cryptsetup is not installed, then we cannot support encrypted devices.
type -P cryptsetup >/dev/null || exit 1 type -P cryptsetup >/dev/null || exit 1
@ -12,12 +14,12 @@ is_crypt() { [[ $(get_fs_type /dev/block/$1) = crypto_LUKS ]]; }
[[ $1 = '-h' ]] && { [[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device) rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about # root lives on a block device, so we can be more precise about
# hostonly checking # hostonly checking
check_block_and_slaves is_crypt "$rootdev" || exit 1 check_block_and_slaves is_crypt "$rootdev" || exit 1
else else
# root is not on a block device, use the shotgun approach # root is not on a block device, use the shotgun approach
blkid | grep -q crypto\?_LUKS || exit 1 blkid | grep -q crypto\?_LUKS || exit 1
fi fi
} }



View File

@ -1,11 +1,13 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# close everything which is not busy # 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


while true; do while true; do
local do_break="y" local do_break="y"
for i in /dev/mapper/luks-*; do 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 done
[ "$do_break" = "y" ] && break [ "$do_break" = "y" ] && break
done done

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# do not ask, if we already have root # do not ask, if we already have root
[ -f /sysroot/proc ] && exit 0 [ -f /sysroot/proc ] && exit 0
@ -37,7 +39,7 @@ if [ -f /etc/crypttab ] && ! getarg rd_NO_CRYPTTAB; then
luksname="$name" luksname="$name"
break break
fi fi
# path used in crypttab # path used in crypttab
else else
cdev=$(readlink -f $dev) cdev=$(readlink -f $dev)
@ -88,12 +90,12 @@ unset keydev_uuid keypath
if [ -n "$keypaths" ]; then if [ -n "$keypaths" ]; then
keydev_uuids="$(getargs rd_LUKS_KEYDEV_UUID)" keydev_uuids="$(getargs rd_LUKS_KEYDEV_UUID)"
[ -n "$keydev_uuids" ] || { [ -n "$keydev_uuids" ] || {
warn 'No UUID of device storing LUKS key specified.' warn 'No UUID of device storing LUKS key specified.'
warn 'It is recommended to set rd_LUKS_KEYDEV_UUID.' warn 'It is recommended to set rd_LUKS_KEYDEV_UUID.'
warn 'Performing scan of *all* devices accessible by UUID...' warn 'Performing scan of *all* devices accessible by UUID...'
} }
tmp=$(foreach_uuid_until "probe_keydev \$full_uuid $keypaths" \ tmp=$(foreach_uuid_until "probe_keydev \$full_uuid $keypaths" \
$keydev_uuids) && { $keydev_uuids) && {
keydev_uuid="${tmp%% *}" keydev_uuid="${tmp%% *}"
keypath="${tmp#* }" keypath="${tmp#* }"
} || { } || {
@ -129,20 +131,20 @@ else
prompt="Password for $device ($sluksname...)" prompt="Password for $device ($sluksname...)"
fi fi
# flock against other interactive activities # flock against other interactive activities
{ flock -s 9; { flock -s 9;
/bin/plymouth ask-for-password \ /bin/plymouth ask-for-password \
--prompt "$prompt" \ --prompt "$prompt" \
--command="/sbin/cryptsetup luksOpen -T1 $device $luksname" --command="/sbin/cryptsetup luksOpen -T1 $device $luksname"
} 9>/.console.lock } 9>/.console.lock
unset sluksname prompt unset sluksname prompt
else else
# flock against other interactive activities # flock against other interactive activities
{ flock -s 9; { flock -s 9;
echo "$device ($luksname) is password protected" echo "$device ($luksname) is password protected"
cryptsetup luksOpen -T5 $device $luksname cryptsetup luksOpen -T5 $device $luksname
} 9>/.console.lock } 9>/.console.lock
fi fi
fi fi
@ -155,4 +157,3 @@ unset device luksname
udevsettle udevsettle


exit 0 exit 0
# vim:ts=8:sw=4:sts=4:et

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
inst cryptsetup inst cryptsetup
inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
inst_hook cmdline 30 "$moddir/parse-crypt.sh" inst_hook cmdline 30 "$moddir/parse-crypt.sh"

View File

@ -1,3 +1,5 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
instmods dm_crypt cbc sha256 xts aes aes_generic aesni-intel aes-x86_64 fpu instmods dm_crypt cbc sha256 xts aes aes_generic aesni-intel aes-x86_64 fpu



View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if getarg rd_NO_LUKS; then if getarg rd_NO_LUKS; then
info "rd_NO_LUKS: removing cryptoluks activation" info "rd_NO_LUKS: removing cryptoluks activation"
rm -f /etc/udev/rules.d/70-luks.rules rm -f /etc/udev/rules.d/70-luks.rules
@ -11,8 +13,8 @@ else
LUKS=$(getargs rd_LUKS_UUID) LUKS=$(getargs rd_LUKS_UUID)
unset settled unset settled
[ -n "$(getargs rd_LUKS_KEYPATH)" ] && \ [ -n "$(getargs rd_LUKS_KEYPATH)" ] && \
[ -z "$(getargs rd_LUKS_KEYDEV_UUID)" ] && \ [ -z "$(getargs rd_LUKS_KEYDEV_UUID)" ] && \
settled='--settled' settled='--settled'


if [ -n "$LUKS" ]; then if [ -n "$LUKS" ]; then
for luksid in $LUKS; do for luksid in $LUKS; do
@ -26,7 +28,7 @@ else
} >> /etc/udev/rules.d/70-luks.rules } >> /etc/udev/rules.d/70-luks.rules


printf '[ -e /dev/disk/by-uuid/*%s* ] || exit 1\n' $luksid \ printf '[ -e /dev/disk/by-uuid/*%s* ] || exit 1\n' $luksid \
>> /initqueue-finished/crypt.sh >> /initqueue-finished/crypt.sh
{ {
printf '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid printf '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
printf 'warn "crypto LUKS UUID "%s" not found"\n' $luksid printf 'warn "crypto LUKS UUID "%s" not found"\n' $luksid
@ -34,9 +36,9 @@ else
done done
else else
echo 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue' $settled \ echo 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue' $settled \
'--unique --onetime --name cryptroot-ask-%k' \ '--unique --onetime --name cryptroot-ask-%k' \
'/sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"' \ '/sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"' \
>> /etc/udev/rules.d/70-luks.rules >> /etc/udev/rules.d/70-luks.rules
fi fi


echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


exit 255 exit 255



View File

@ -1 +1,3 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
strstr "$(cat /proc/misc)" device-mapper || modprobe dm_mod strstr "$(cat /proc/misc)" device-mapper || modprobe dm_mod

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


modinfo -k $kernel dm_mod >/dev/null 2>&1 && \ modinfo -k $kernel dm_mod >/dev/null 2>&1 && \
inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh" inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh"

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


instmods =drivers/md instmods =drivers/md



View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# We depend on dm_mod being loaded # We depend on dm_mod being loaded
[ "$1" = "-d" ] && echo dm [ "$1" = "-d" ] && echo dm
@ -16,12 +18,12 @@ is_dmraid() { get_fs_type /dev/block/$1 |grep -v linux_raid_member | \
[[ $1 = '-h' ]] && { [[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device) rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about # root lives on a block device, so we can be more precise about
# hostonly checking # hostonly checking
check_block_and_slaves is_dmraid "$rootdev" || exit 1 check_block_and_slaves is_dmraid "$rootdev" || exit 1
else else
# root is not on a block device, use the shotgun approach # root is not on a block device, use the shotgun approach
dmraid -r | grep -q ok || exit 1 dmraid -r | grep -q ok || exit 1
fi fi
} }



View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


. /lib/dracut-lib.sh . /lib/dracut-lib.sh


@ -20,19 +22,19 @@ echo $SETS|vinfo
if [ -n "$DM_RAIDS" ]; then if [ -n "$DM_RAIDS" ]; then
# only activate specified DM RAIDS # only activate specified DM RAIDS
for r in $DM_RAIDS; do for r in $DM_RAIDS; do
for s in $SETS; do for s in $SETS; do
if [ "${s##$r}" != "$s" ]; then if [ "${s##$r}" != "$s" ]; then
info "Activating $s" info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
[ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" 2>&1 | vinfo [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" 2>&1 | vinfo
udevsettle udevsettle
fi fi
done done
done done
else else
# scan and activate all DM RAIDS # scan and activate all DM RAIDS
for s in $SETS; do for s in $SETS; do
info "Activating $s" info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
[ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" 2>&1 | vinfo [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" 2>&1 | vinfo
done done

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
dracut_install dmraid partx kpartx dracut_install dmraid partx kpartx


inst dmeventd inst dmeventd

View File

@ -1,3 +1,5 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# nodmraid for anaconda / rc.sysinit compatibility # nodmraid for anaconda / rc.sysinit compatibility
if getarg rd_NO_DM || getarg nodmraid; then if getarg rd_NO_DM || getarg nodmraid; then
info "rd_NO_DM: removing DM RAID activation" info "rd_NO_DM: removing DM RAID activation"

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# if dmsetup is not installed, then we cannot support fedora/red hat # if dmsetup is not installed, then we cannot support fedora/red hat
# style live images # style live images

View File

@ -1,15 +1,17 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if [ "${root%%:*}" = "live" ]; then if [ "${root%%:*}" = "live" ]; then
{ {
printf 'KERNEL=="%s", SYMLINK+="live"\n' \ printf 'KERNEL=="%s", SYMLINK+="live"\n' \
${root#live:/dev/} ${root#live:/dev/}
printf 'SYMLINK=="%s", SYMLINK+="live"\n' \ printf 'SYMLINK=="%s", SYMLINK+="live"\n' \
${root#live:/dev/} ${root#live:/dev/}
} >> /dev/.udev/rules.d/99-live-mount.rules } >> /dev/.udev/rules.d/99-live-mount.rules
{ {
printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \ printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \
${root#live:/dev/} ${root#live:/dev/}
printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \ printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \
${root#live:/dev/} ${root#live:/dev/}
} >> /etc/udev/rules.d/99-live-squash.rules } >> /etc/udev/rules.d/99-live-squash.rules
echo '[ -e /dev/root ]' > /initqueue-finished/dmsquash.sh echo '[ -e /dev/root ]' > /initqueue-finished/dmsquash.sh
fi fi

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


. /lib/dracut-lib.sh . /lib/dracut-lib.sh
[ -f /tmp/root.info ] && . /tmp/root.info [ -f /tmp/root.info ] && . /tmp/root.info
@ -32,8 +34,8 @@ getarg check || check=""
if [ -n "$check" ]; then if [ -n "$check" ]; then
checkisomd5 --verbose $livedev || : checkisomd5 --verbose $livedev || :
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "CD check failed!" die "CD check failed!"
exit 1 exit 1
fi fi
fi fi


@ -79,7 +81,7 @@ do_live_overlay() {
if [ -f /overlayfs$pathspec -a -w /overlayfs$pathspec ]; then if [ -f /overlayfs$pathspec -a -w /overlayfs$pathspec ]; then
losetup $OVERLAY_LOOPDEV /overlayfs$pathspec losetup $OVERLAY_LOOPDEV /overlayfs$pathspec
if [ -n "$reset_overlay" ]; then if [ -n "$reset_overlay" ]; then
dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 2>/dev/null dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 2>/dev/null
fi fi
setup="yes" setup="yes"
fi fi
@ -88,8 +90,8 @@ do_live_overlay() {


if [ -z "$setup" ]; then if [ -z "$setup" ]; then
if [ -n "$devspec" -a -n "$pathspec" ]; then if [ -n "$devspec" -a -n "$pathspec" ]; then
warn "Unable to find persistent overlay; using temporary" warn "Unable to find persistent overlay; using temporary"
sleep 5 sleep 5
fi fi


dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
@ -124,7 +126,7 @@ fi


# we might have just an embedded ext3 to use as rootfs (uncompressed live) # we might have just an embedded ext3 to use as rootfs (uncompressed live)
if [ -e /dev/.initramfs/live/${live_dir}/ext3fs.img ]; then if [ -e /dev/.initramfs/live/${live_dir}/ext3fs.img ]; then
EXT3FS="/dev/.initramfs/live/${live_dir}/ext3fs.img" EXT3FS="/dev/.initramfs/live/${live_dir}/ext3fs.img"
fi fi


if [ -n "$EXT3FS" ] ; then if [ -n "$EXT3FS" ] ; then
@ -136,7 +138,7 @@ fi


# we might have an embedded ext3 on squashfs to use as rootfs (compressed live) # we might have an embedded ext3 on squashfs to use as rootfs (compressed live)
if [ -e /dev/.initramfs/live/${live_dir}/squashfs.img ]; then if [ -e /dev/.initramfs/live/${live_dir}/squashfs.img ]; then
SQUASHED="/dev/.initramfs/live/${live_dir}/squashfs.img" SQUASHED="/dev/.initramfs/live/${live_dir}/squashfs.img"
fi fi


if [ -e "$SQUASHED" ] ; then if [ -e "$SQUASHED" ] ; then

View File

@ -1,7 +1,9 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if [ "${root%%:*}" = "liveiso" ]; then if [ "${root%%:*}" = "liveiso" ]; then
{ {
printf 'KERNEL=="loop0", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root `/sbin/losetup -f --show %s`"\n' \ printf 'KERNEL=="loop0", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root `/sbin/losetup -f --show %s`"\n' \
${root#liveiso:} ${root#liveiso:}
} >> /etc/udev/rules.d/99-liveiso-mount.rules } >> /etc/udev/rules.d/99-liveiso-mount.rules
echo '[ -e /dev/root ]' > /initqueue-finished/dmsquash.sh echo '[ -e /dev/root ]' > /initqueue-finished/dmsquash.sh
fi fi

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
dracut_install umount dracut_install umount
inst dmsetup inst dmsetup
inst blkid inst blkid

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# live images are specified with # live images are specified with
# root=live:backingdev # root=live:backingdev


@ -16,24 +18,24 @@ fi
[ "${liveroot%%:*}" = "live" ] || return [ "${liveroot%%:*}" = "live" ] || return


case "$liveroot" in case "$liveroot" in
live:LABEL=*|LABEL=*) live:LABEL=*|LABEL=*) \
root="${root#live:}" root="${root#live:}"
root="$(echo $root | sed 's,/,\\x2f,g')" root="$(echo $root | sed 's,/,\\x2f,g')"
root="live:/dev/disk/by-label/${root#LABEL=}" root="live:/dev/disk/by-label/${root#LABEL=}"
rootok=1 ;; rootok=1 ;;
live:CDLABEL=*|CDLABEL=*) live:CDLABEL=*|CDLABEL=*) \
root="${root#live:}" root="${root#live:}"
root="$(echo $root | sed 's,/,\\x2f,g')" root="$(echo $root | sed 's,/,\\x2f,g')"
root="live:/dev/disk/by-label/${root#CDLABEL=}" root="live:/dev/disk/by-label/${root#CDLABEL=}"
rootok=1 ;; rootok=1 ;;
live:UUID=*|UUID=*) live:UUID=*|UUID=*) \
root="${root#live:}" root="${root#live:}"
root="live:/dev/disk/by-uuid/${root#UUID=}" root="live:/dev/disk/by-uuid/${root#UUID=}"
rootok=1 ;; rootok=1 ;;
live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo]) live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
root="${root#live:}" root="${root#live:}"
root="liveiso:${root}" root="liveiso:${root}"
rootok=1 ;; rootok=1 ;;
live:/dev/*) live:/dev/*)
rootok=1 ;; rootok=1 ;;
esac esac

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf [ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf
dracut_install $(find /etc/modprobe.d/ -type f -name '*.conf') dracut_install $(find /etc/modprobe.d/ -type f -name '*.conf')
inst_hook cmdline 01 "$moddir/parse-kernel.sh" inst_hook cmdline 01 "$moddir/parse-kernel.sh"

View File

@ -1,9 +1,11 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if [[ -z $drivers ]]; then if [[ -z $drivers ]]; then
block_module_test() { block_module_test() {
local blockfuncs='ahci_init_controller|ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device' local blockfuncs='ahci_init_controller|ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'


egrep -q "$blockfuncs" "$1" egrep -q "$blockfuncs" "$1"
} }
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc
hostonly='' instmods pcmcia firewire-ohci hostonly='' instmods pcmcia firewire-ohci
@ -16,19 +18,19 @@ if [[ -z $drivers ]]; then
instmods $(filter_kernel_modules block_module_test) instmods $(filter_kernel_modules block_module_test)
# if not on hostonly mode, install all known filesystems if the required list is not set via the filesystems variable # if not on hostonly mode, install all known filesystems if the required list is not set via the filesystems variable
if ! [[ $hostonly ]]; then if ! [[ $hostonly ]]; then
if [[ -z $filesystems ]]; then if [[ -z $filesystems ]]; then
instmods '=fs' instmods '=fs'
# hardcoded list of exceptions # hardcoded list of exceptions
# to save a lot of space # to save a lot of space
rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2 rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
else else
instmods $filesystems instmods $filesystems
fi fi
else else
hostonly='' instmods $(get_fs_type "/dev/block/$(find_root_block_device)") hostonly='' instmods $(get_fs_type "/dev/block/$(find_root_block_device)")
fi fi
else else
hostonly='' instmods $drivers $filesystems hostonly='' instmods $drivers $filesystems
fi fi


[[ $add_drivers ]] && hostonly='' instmods $add_drivers [[ $add_drivers ]] && hostonly='' instmods $add_drivers

View File

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


for p in $(getargs rdloaddriver=); do for p in $(getargs rdloaddriver=); do
modprobe $p modprobe $p
done done

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# We depend on dm_mod being loaded # We depend on dm_mod being loaded
[ "$1" = "-d" ] && echo dm [ "$1" = "-d" ] && echo dm
@ -14,12 +16,12 @@ is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; }
[[ $1 = '-h' ]] && { [[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device) rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about # root lives on a block device, so we can be more precise about
# hostonly checking # hostonly checking
check_block_and_slaves is_lvm "$rootdev" || exit 1 check_block_and_slaves is_lvm "$rootdev" || exit 1
else else
# root is not on a block device, use the shotgun approach # root is not on a block device, use the shotgun approach
blkid | grep -q LVM2_member || exit 1 blkid | grep -q LVM2_member || exit 1
fi fi
} }



View File

@ -1,14 +1,16 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
inst lvm inst lvm


inst_rules "$moddir/64-lvm.rules" inst_rules "$moddir/64-lvm.rules"


if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then
if [ -f /etc/lvm/lvm.conf ]; then if [ -f /etc/lvm/lvm.conf ]; then
inst /etc/lvm/lvm.conf inst /etc/lvm/lvm.conf
# FIXME: near-term hack to establish read-only locking; # FIXME: near-term hack to establish read-only locking;
# use command-line lvm.conf editor once it is available # use command-line lvm.conf editor once it is available
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' ${initdir}/etc/lvm/lvm.conf sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' ${initdir}/etc/lvm/lvm.conf
fi fi
fi fi



View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# run lvm scan if udev has settled # run lvm scan if udev has settled


@ -11,24 +13,24 @@ LVS=$(getargs rd_LVM_LV=)
# build a list of devices to scan # build a list of devices to scan
lvmdevs=$( lvmdevs=$(
for f in /tmp/.lvm_scan-*; do for f in /tmp/.lvm_scan-*; do
[ -e "$f" ] || continue [ -e "$f" ] || continue
echo -n "${f##/tmp/.lvm_scan-} " echo -n "${f##/tmp/.lvm_scan-} "
done done
) )


if [ ! -e /etc/lvm/lvm.conf ]; then if [ ! -e /etc/lvm/lvm.conf ]; then
{ {
echo 'devices {'; echo 'devices {';
echo -n ' filter = [ ' echo -n ' filter = [ '
for dev in $lvmdevs; do for dev in $lvmdevs; do
printf '"a|^/dev/%s$|", ' $dev; printf '"a|^/dev/%s$|", ' $dev;
done; done;
echo '"r/.*/" ]'; echo '"r/.*/" ]';
echo '}'; echo '}';
# establish read-only locking # establish read-only locking
echo 'global {'; echo 'global {';
echo ' locking_type = 4'; echo ' locking_type = 4';
echo '}'; echo '}';
} > /etc/lvm/lvm.conf } > /etc/lvm/lvm.conf
lvmwritten=1 lvmwritten=1
fi fi
@ -50,28 +52,28 @@ nopoll=$(
# hopefully this output format will never change, e.g.: # hopefully this output format will never change, e.g.:
# LVM version: 2.02.53(1) (2009-09-25) # LVM version: 2.02.53(1) (2009-09-25)
lvm version 2>/dev/null | \ lvm version 2>/dev/null | \
( (
IFS=. read maj min sub; IFS=. read maj min sub;
maj=${maj##*:}; maj=${maj##*:};
sub=${sub%% *}; sub=${sub%%\(*}; sub=${sub%% *}; sub=${sub%%\(*};
check_lvm_ver $maj $min $sub && \ check_lvm_ver $maj $min $sub && \
echo " --poll n ") 2>/dev/null ) echo " --poll n ") 2>/dev/null )


if [ -n "$LVS" ] ; then if [ -n "$LVS" ] ; then
info "Scanning devices $lvmdevs for LVM logical volumes $LVS" info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
lvm lvscan --ignorelockingfailure 2>&1 | vinfo lvm lvscan --ignorelockingfailure 2>&1 | vinfo
lvm lvchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $LVS 2>&1 | vinfo lvm lvchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $LVS 2>&1 | vinfo
fi fi


if [ -z "$LVS" -o -n "$VGS" ]; then if [ -z "$LVS" -o -n "$VGS" ]; then
info "Scanning devices $lvmdevs for LVM volume groups $VGS" info "Scanning devices $lvmdevs for LVM volume groups $VGS"
lvm vgscan --ignorelockingfailure 2>&1 | vinfo lvm vgscan --ignorelockingfailure 2>&1 | vinfo
lvm vgchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $VGS 2>&1 | vinfo lvm vgchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $VGS 2>&1 | vinfo
fi fi


if [ "$lvmwritten" ]; then if [ "$lvmwritten" ]; then
rm -f /etc/lvm/lvm.conf rm -f /etc/lvm/lvm.conf
ln -s /sbin/lvm-cleanup /pre-pivot/30-lvm-cleanup.sh 2>/dev/null ln -s /sbin/lvm-cleanup /pre-pivot/30-lvm-cleanup.sh 2>/dev/null
ln -s /sbin/lvm-cleanup /pre-pivot/31-lvm-cleanup.sh 2>/dev/null ln -s /sbin/lvm-cleanup /pre-pivot/31-lvm-cleanup.sh 2>/dev/null
fi fi
unset lvmwritten unset lvmwritten

View File

@ -1,3 +1,5 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if [ -e /etc/lvm/lvm.conf ] && getarg rd_NO_LVMCONF; then if [ -e /etc/lvm/lvm.conf ] && getarg rd_NO_LVMCONF; then
rm -f /etc/lvm/lvm.conf rm -f /etc/lvm/lvm.conf
fi fi

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# No mdadm? No mdraid support. # No mdadm? No mdraid support.
type -P mdadm >/dev/null || exit 1 type -P mdadm >/dev/null || exit 1
@ -11,12 +13,12 @@ is_mdraid() { [[ -d "/sys/dev/block/$1/md" ]]; }
[[ $1 = '-h' ]] && { [[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device) rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about # root lives on a block device, so we can be more precise about
# hostonly checking # hostonly checking
check_block_and_slaves is_mdraid "$rootdev" || exit 1 check_block_and_slaves is_mdraid "$rootdev" || exit 1
else else
# root is not on a block device, use the shotgun approach # root is not on a block device, use the shotgun approach
blkid | egrep -q '(linux|isw)_raid' || exit 1 blkid | egrep -q '(linux|isw)_raid' || exit 1
fi fi
} }



View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


dracut_install mdadm partx dracut_install mdadm partx



View File

@ -1,3 +1,5 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
instmods =drivers/md instmods =drivers/md



View File

@ -1,2 +1,4 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
info "rd_NO_MDIMSM: no MD RAID for imsm/isw raids" info "rd_NO_MDIMSM: no MD RAID for imsm/isw raids"
udevproperty rd_NO_MDIMSM=1 udevproperty rd_NO_MDIMSM=1

View File

@ -1,3 +1,5 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
for f in /initqueue-settled/mdcontainer_start* /initqueue-settled/mdraid_start* /initqueue-settled/mdadm_auto*; do for f in /initqueue-settled/mdcontainer_start* /initqueue-settled/mdraid_start* /initqueue-settled/mdadm_auto*; do
[ -e $f ] && return 1 [ -e $f ] && return 1
done done

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
. /lib/dracut-lib.sh . /lib/dracut-lib.sh


info "Autoassembling MD Raid" info "Autoassembling MD Raid"

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
. /lib/dracut-lib.sh . /lib/dracut-lib.sh


md=$1 md=$1

View File

@ -1,3 +1,5 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# save state dir for mdmon/mdadm for the real root # save state dir for mdmon/mdadm for the real root
mkdir /dev/.mdadm mkdir /dev/.mdadm
[ -e /var/run/mdadm ] && rm -fr /var/run/mdadm [ -e /var/run/mdadm ] && rm -fr /var/run/mdadm

View File

@ -1,16 +1,19 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

# stop everything which is not busy # stop everything which is not busy
for i in /dev/md* /dev/md/*; do for i in /dev/md* /dev/md/*; do
[ -b $i ] || continue [ -b $i ] || continue


mddetail=$(udevadm info --query=property --name=$i) mddetail=$(udevadm info --query=property --name=$i)
case "$mddetail" in case "$mddetail" in
*MD_LEVEL=container*) *MD_LEVEL=container*)
;; ;;
*DEVTYPE=partition*) *DEVTYPE=partition*)
;; ;;
*) *)
mdadm --stop $i >/dev/null 2>&1 mdadm --stop $i >/dev/null 2>&1
;; ;;
esac esac
done done

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


. /lib/dracut-lib.sh . /lib/dracut-lib.sh
# run mdadm if udev has settled # run mdadm if udev has settled
@ -10,12 +12,12 @@ mdadm -Is --run 2>&1 | vinfo
# there could still be some leftover devices # there could still be some leftover devices
# which have had a container added # which have had a container added
for md in /dev/md[0-9]* /dev/md/*; do for md in /dev/md[0-9]* /dev/md/*; do
[ -b "$md" ] || continue [ -b "$md" ] || continue
udevinfo="$(udevadm info --query=env --name=$md)" udevinfo="$(udevadm info --query=env --name=$md)"
strstr "$udevinfo" "MD_UUID=" && continue strstr "$udevinfo" "MD_UUID=" && continue
strstr "$udevinfo" "MD_LEVEL=container" && continue strstr "$udevinfo" "MD_LEVEL=container" && continue
strstr "$udevinfo" "DEVTYPE=partition" && continue strstr "$udevinfo" "DEVTYPE=partition" && continue
mdadm --run "$md" 2>&1 | vinfo mdadm --run "$md" 2>&1 | vinfo
done done
unset udevinfo unset udevinfo



View File

@ -1,3 +1,5 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if getarg rd_NO_MD; then if getarg rd_NO_MD; then
info "rd_NO_MD: removing MD RAID activation" info "rd_NO_MD: removing MD RAID activation"
udevproperty rd_NO_MD=1 udevproperty rd_NO_MD=1
@ -6,21 +8,21 @@ else


# rewrite the md rules to only process the specified raid array # rewrite the md rules to only process the specified raid array
if [ -n "$MD_UUID" ]; then if [ -n "$MD_UUID" ]; then
for f in /etc/udev/rules.d/65-md-incremental*.rules; do for f in /etc/udev/rules.d/65-md-incremental*.rules; do
[ -e "$f" ] || continue [ -e "$f" ] || continue
mv $f ${f}.bak mv $f ${f}.bak
while read line; do while read line; do
if [ "${line%%UUID CHECK}" != "$line" ]; then if [ "${line%%UUID CHECK}" != "$line" ]; then
for uuid in $MD_UUID; do for uuid in $MD_UUID; do
printf 'ENV{MD_UUID}=="%s", GOTO="do_md_inc"\n' $uuid printf 'ENV{MD_UUID}=="%s", GOTO="do_md_inc"\n' $uuid
done; done;
printf 'GOTO="md_inc_end"\n'; printf 'GOTO="md_inc_end"\n';
else else
echo $line; echo $line;
fi fi
done < ${f}.bak > $f done < ${f}.bak > $f
rm ${f}.bak rm ${f}.bak
done done
fi fi
fi fi


@ -31,7 +33,7 @@ if [ -e /etc/mdadm.conf ] && ! getarg rd_NO_MDADMCONF; then
fi fi


if getarg rd_NO_MDADMCONF; then if getarg rd_NO_MDADMCONF; then
rm -f /etc/mdadm/mdadm.conf /etc/mdadm.conf rm -f /etc/mdadm/mdadm.conf /etc/mdadm.conf
fi fi


# noiswmd nodmraid for anaconda / rc.sysinit compatibility # noiswmd nodmraid for anaconda / rc.sysinit compatibility

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


# if there's no multipath binary, no go. # if there's no multipath binary, no go.
type -P multipath >/dev/null || exit 1 type -P multipath >/dev/null || exit 1

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


for f in \ for f in \
/sbin/dmsetup \ /sbin/dmsetup \

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


mp_mod_test() { mp_mod_test() {
local mpfuncs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target' local mpfuncs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target'

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if [ -e /etc/multipath.conf ]; then if [ -e /etc/multipath.conf ]; then
HARD="" HARD=""

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh


if [ -e /etc/multipath.conf -a -e /etc/multipath/wwids ]; then if [ -e /etc/multipath.conf -a -e /etc/multipath/wwids ]; then
modprobe dm-multipath modprobe dm-multipath

View File

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
arch=$(uname -m) arch=$(uname -m)
[ "$arch" = "s390" -o "$arch" = "s390x" ] || exit 1 [ "$arch" = "s390" -o "$arch" = "s390x" ] || exit 1



Some files were not shown because too many files have changed in this diff Show More