Compare commits

..

34 Commits
015 ... 016

Author SHA1 Message Date
Harald Hoyer
6bee336909 Version 16 2012-02-15 18:05:34 +01:00
Harald Hoyer
5c4bb360e3 dracut.spec: add missing modules 2012-02-15 17:59:46 +01:00
Harald Hoyer
969394f503 95nfs/nfs-lib.sh: do not bail out at sourcing in nfsroot_from_dhcp()
nfsroot_from_dhcp() returned with failure if one of
/tmp/net.$iface.override /tmp/dhclient.$iface.dhcpopts was missing
2012-02-15 16:39:41 +01:00
Harald Hoyer
4977febf46 s/bash/sh for all new *-lib.sh 2012-02-15 15:46:24 +01:00
Will Woods
285e81c9e2 add img-lib: a library for handling filesystem images
img-lib handles identifying and unpacking archives (uncompressed or
compressed) and filesystem images.

Currently tar and gzip are required; cpio and xz are optional, and bzip2
is supported but unused.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
d663f5aeb0 add set_http_header to url-lib
This allows you to set custom headers for curl to send with HTTP
requests.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
370329ca3b url-lib: add support for NFS
This adds nfs_fetch_url to allow fetching arbitrary files from NFS.

This means that livenet can now run using an NFS-mounted live image,
which reduces memory usage by a lot.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
5978983b30 90livenet: port to url-lib
This makes the livenetroot module use url-lib for fetching its root
image/filesystem. There's also some minor tweaks for POSIX compliance.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
753c82d0e6 add module 45url-lib
url-lib adds some functions for dealing with URLs (mostly for fetching
files, for the moment).

It uses curl to handle http/https/ftp URLs, but it can be extended by other
modules at runtime by using the "add_url_handler" function.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
9fcfa04ca9 port nfsroot to nfs-lib
Rewrite nfsroot to use nfs-lib. The functionality should be unchanged.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
9c463909d6 95nfs: add nfs-lib.sh
nfs-lib.sh contains a bunch of functions used to parse NFS "url"s of
various types, pull nfs information out of dhcp info, and actually
perform nfs mounts sanely.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
9d169a07ce 40network: add net-lib.sh
net-lib.sh is a library of useful functions for network stuff.

More things may get added/moved here in the future.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Harald Hoyer
dee929cded 99base/init: removed redirection of mount errors to /dev/null 2012-02-15 15:46:24 +01:00
Harald Hoyer
e0e2fb26c9 90kernel-modules: removed hard-removal of "ocfs2"
put omit_driver+=" ocfs2 " in the distribution configuration file
2012-02-15 15:46:23 +01:00
Harald Hoyer
fcbcb2521c dracut: add "--omit-driver" 2012-02-15 15:46:23 +01:00
Harald Hoyer
28f0b27fb9 TEST-40-NBD: correct symlinks by rerunning ldconfig 2012-02-15 15:08:34 +01:00
Harald Hoyer
0ddc098eb0 TEST-12-RAID-DEG: improve test case 2012-02-15 15:08:29 +01:00
Harald Hoyer
11c0e7d44e 99base/init: reload udev rules after "pre-trigger" hook 2012-02-15 11:32:21 +01:00
Harald Hoyer
dfb08e9f1c removed now useless cleanup hooks
in Fedora 17, we unpack /boot/initramfs-$(uname -r).img
on shutdown for a pivot root to disassemble the root device
2012-02-15 10:08:59 +01:00
Harald Hoyer
e539fa9980 90mdraid: add "--offroot" support 2012-02-13 21:16:31 +01:00
Harald Hoyer
e76921a58e 95terminfo/module-setup.sh: check for terminfo/l/linux
on Fedora 17 the old check found /etc/terminfo, but this directory is
emtpy.
2012-02-13 21:15:51 +01:00
Harald Hoyer
96d22bd7d6 test: fixed terminfo location 2012-02-13 21:15:22 +01:00
Harald Hoyer
927d9273c4 Makefile: s/dracut-initramfs-backup.sh/dracut-initramfs-restore.sh/ 2012-02-13 18:20:12 +01:00
Harald Hoyer
56a4cffd30 98integrity/module-setup.sh: depend on selinux dracut module 2012-02-13 18:17:40 +01:00
Harald Hoyer
682a2a9d1a 90kernel-modules/module-setup.sh: add "ata_piix" to hardcoded modules 2012-02-13 18:16:48 +01:00
Harald Hoyer
0b1296aa4f dracut.xml: mention log_buf_len=1M for rd.debug 2012-02-13 18:16:28 +01:00
Harald Hoyer
fb67e4aa36 shutdown on demand
Do not save and restore the initramfs, but instead, just unpack the
default initramfs for shutdown on shutdown.
2012-02-13 07:08:08 +01:00
Harald Hoyer
4cfd24d179 Backup and restore /run/initramfs via systemd services
This saves the space /run/initramfs is taking for the shutdown
2012-02-10 11:14:31 +01:00
Harald Hoyer
81dcf7c90a 99shutdown/shutdown: don't do console_init on shutdown emergency 2012-02-09 14:16:31 +01:00
Harald Hoyer
075de7be45 98usrmount/mount-usr.sh: remove extra slash
otherwise we have /sysroot//usr in fstab
2012-02-09 13:58:49 +01:00
Harald Hoyer
7b2d3d995c dracut: honor binaries in sbin first 2012-02-09 13:58:13 +01:00
Harald Hoyer
d20d307d69 lsinitrd: silence xz test 2012-02-09 11:36:21 +01:00
Harald Hoyer
12018c91ea TEST-15-BTRFSRAID: write diskimage to tmp dir 2012-02-08 17:02:57 +01:00
Harald Hoyer
68910ba4a5 dracut: setup clean PATH w/o existing one 2012-02-08 17:02:17 +01:00
67 changed files with 810 additions and 297 deletions

View File

@@ -1,4 +1,4 @@
VERSION=015
VERSION=016
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix ?= /usr
@@ -40,6 +40,7 @@ install: doc
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions
install -m 0755 dracut-logger $(DESTDIR)$(pkglibdir)/dracut-logger
install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore
cp -arx modules.d $(DESTDIR)$(pkglibdir)
install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8/dracut.8
install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8/dracut-catimages.8
@@ -47,6 +48,12 @@ install: doc
install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5/dracut.conf.5
install -m 0644 dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.cmdline.7
ln -s dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
if [ -n "$(systemdsystemunitdir)" ]; then \
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
install -m 0644 dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir); \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants; \
ln -s ../dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants/dracut-shutdown.service; \
fi
clean:
$(RM) *~
@@ -77,12 +84,14 @@ rpm: dracut-$(VERSION).tar.bz2
( mv "$$rpmbuild"/noarch/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
syncheck:
@ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \
@ret=0;for i in dracut-initramfs-restore.sh dracut-logger \
modules.d/99base/init modules.d/*/*.sh; do \
[ "$${i##*/}" = "module-setup.sh" ] && continue; \
[ "$${i##*/}" = "caps.sh" ] && continue; \
dash -n "$$i" ; ret=$$(($$ret+$$?)); \
done;exit $$ret
@ret=0;for i in dracut modules.d/02caps/caps.sh modules.d/*/module-setup.sh; do \
@ret=0;for i in mkinitrd-dracut.sh dracut modules.d/02caps/caps.sh \
modules.d/*/module-setup.sh; do \
bash -n "$$i" ; ret=$$(($$ret+$$?)); \
done;exit $$ret

14
NEWS
View File

@@ -1,3 +1,17 @@
dracut-016
==========
- fixed lsinitrd
- honor binaries in sbin first
- fixed usrmount module
- added systemd service for shutdown
- fixed terminfo on distros with /usr/share/terminfo
- reload udev rules after "pre-trigger" hook
- improved test suite
- new parameter "--omit-drivers" and new conf param omit_drivers
- "--offroot" support for mdraid
- new libs: net-lib.sh, nfs-lib.sh, url-lib.sh, img-lib.sh
full of functions to use in your dracut module
dracut-015
==========
- hostonly mode automatically adds command line options for root and /usr

59
dracut
View File

@@ -40,8 +40,10 @@ Creates initial ramdisk images for preloading modules
-a, --add [LIST] Add a space-separated list of dracut modules.
-d, --drivers [LIST] Specify a space-separated list of kernel modules to
exclusively include in the initramfs.
--add-drivers [LIST] Specify a space-separated list of kernel
--add-drivers [LIST] Specify a space-separated list of kernel
modules to add to the initramfs.
--omit-drivers [LIST] Specify a space-separated list of kernel
modules not to add to the initramfs.
--filesystems [LIST] Specify a space-separated list of kernel filesystem
modules to exclusively include in the generic
initramfs.
@@ -210,6 +212,7 @@ while (($# > 0)); do
-a|--add) push_arg add_dracutmodules_l "$@" || shift;;
--force-add) push_arg force_add_dracutmodules_l "$@" || shift;;
--add-drivers) push_arg add_drivers_l "$@" || shift;;
--omit-drivers) push_arg omit_drivers_l "$@" || shift;;
-m|--modules) push_arg dracutmodules_l "$@" || shift;;
-o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
-d|--drivers) push_arg drivers_l "$@" || shift;;
@@ -279,14 +282,15 @@ if ! [[ $kernel ]]; then
fi
[[ $outfile ]] || outfile="/boot/initramfs-$kernel.img"
for i in /usr/bin /bin /usr/sbin /sbin; do
for i in /usr/sbin /sbin /usr/bin /bin; do
rl=$i
if [ -L "$i" ]; then
rl=$(readlink -f $i)
fi
PATH="$PATH:$rl"
NPATH+=":$rl"
done
export PATH
export PATH="${NPATH#:}"
unset NPATH
unset LD_LIBRARY_PATH
unset GREP_OPTIONS
@@ -340,13 +344,6 @@ if (( ${#force_add_dracutmodules_l[@]} )); then
done
fi
if (( ${#add_drivers_l[@]} )); then
while pop add_drivers_l val; do
add_drivers+=" $val "
done
fi
if (( ${#fscks_l[@]} )); then
while pop fscks_l val; do
fscks+=" $val "
@@ -386,13 +383,6 @@ if (( ${#omit_dracutmodules_l[@]} )); then
done
fi
if (( ${#drivers_l[@]} )); then
drivers=''
while pop drivers_l val; do
drivers+="$val "
done
fi
if (( ${#filesystems_l[@]} )); then
filesystems=''
while pop filesystems_l val; do
@@ -465,6 +455,37 @@ fi
dracutfunctions=$dracutbasedir/dracut-functions
export dracutfunctions
if (( ${#drivers_l[@]} )); then
drivers=''
while pop drivers_l val; do
drivers+="$val "
done
fi
drivers=${drivers/-/_}
if (( ${#add_drivers_l[@]} )); then
while pop add_drivers_l val; do
add_drivers+=" $val "
done
fi
add_drivers=${add_drivers/-/_}
if (( ${#omit_drivers_l[@]} )); then
while pop omit_drivers_l val; do
omit_drivers+=" $val "
done
fi
omit_drivers=${omit_drivers/-/_}
unset omit_drivers_corrected
for d in $omit_drivers; do
strstr " $drivers $add_drivers " " $d " && continue
omit_drivers_corrected+=" $d "
done
omit_drivers=$omit_drivers_corrected
unset omit_drivers_corrected
ddebug "Executing $0 $dracut_args"
[[ $do_list = yes ]] && {
@@ -603,7 +624,7 @@ done
export initdir dracutbasedir dracutmodules drivers \
fw_dir drivers_dir debug no_kernel kernel_only \
add_drivers mdadmconf lvmconf filesystems \
add_drivers omit_drivers mdadmconf lvmconf filesystems \
use_fstab fstab_lines libdir usrlibdir fscks nofscks cttyhack \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug host_fs_types host_devs sshkey

View File

@@ -927,6 +927,17 @@ install_kmod_with_fw() {
# no need to go further if the module is already installed
[[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \
&& return 0
if [[ $omit_drivers ]]; then
local _kmod=${1##*/}
_kmod=${_kmod%.ko}
_kmod=${_kmod/-/_}
if strstr " $omit_drivers " " $_kmod " ; then
dinfo "Omitting driver $_kmod"
return 1
fi
fi
inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" \
|| return $?

View File

@@ -0,0 +1,10 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
cd /run/initramfs
IMG="/boot/initramfs-$(uname -r).img"
[ -f .need_shutdown -a -f "$IMG" ] || exit 1
zcat "$IMG" | cpio -id >/dev/null 2>&1
rm .need_shutdown

18
dracut-shutdown.service Normal file
View File

@@ -0,0 +1,18 @@
# This file is part of systemd.
#
# systemd 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.
[Unit]
Description=Restore /run/initramfs
After=getty@tty1.service prefdm.service
Before=reboot.service
DefaultDependencies=no
ConditionPathExists=/run/initramfs/.need_shutdown
[Service]
ExecStart=/usr/lib/dracut/dracut-initramfs-restore
Type=oneshot
RemainAfterExit=yes

View File

@@ -196,6 +196,20 @@ The kernel modules have to be specified without the &quot;.ko&quot; suffix. This
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--omit-drivers&nbsp;<replaceable>&lt;list of kernel modules&gt;</replaceable></option>
</term>
<listitem>
<para>specify a space-separated list of kernel modules not to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --omit-drivers "kmodule1 kmodule2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--filesystems&nbsp;<replaceable>&lt;list of filesystems&gt;</replaceable></option>

View File

@@ -82,6 +82,16 @@ The kernel modules have to be specified without the &quot;.ko&quot; suffix.</par
<listitem>
<para>Specify a space-separated list of kernel
modules to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>omit_drivers+=&quot;&nbsp;<replaceable>&lt;kernel modules&gt;</replaceable>&nbsp;&quot;</envar>
</term>
<listitem>
<para>Specify a space-separated list of kernel
modules not to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix.</para>
</listitem>
</varlistentry>

View File

@@ -4,7 +4,7 @@
i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP"
add_dracutmodules+=" rpmversion "
omit_dracutmodules+=" dash "
omit_drivers+=" ocfs2 "
stdloglvl=3
prefix=/run/initramfs
realinitpath="/usr/lib/systemd/systemd"
install_items+=" vi /etc/virc ps grep cat rm openvt "

View File

@@ -27,6 +27,7 @@ Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar
BuildArch: noarch
BuildRequires: dash bash git
%if 0%{?fedora} || 0%{?rhel} > 6
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%endif
@@ -51,6 +52,10 @@ Obsoletes: nash <= 6.0.93
Obsoletes: libbdevid-python <= 6.0.93
%endif
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
BuildRequires: systemd-units
%endif
%if 0%{?suse_version} > 9999
Obsoletes: mkinitrd < 2.6.1
Provides: mkinitrd = 2.6.1
@@ -161,7 +166,8 @@ rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT \
libdir=%{_prefix}/lib \
bindir=%{_bindir} \
sysconfdir=/etc mandir=%{_mandir}
sysconfdir=/etc mandir=%{_mandir} \
systemdsystemunitdir=%{_unitdir}
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/10rpmversion/dracut-version
@@ -217,6 +223,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{dracutlibdir}/modules.d
%{dracutlibdir}/dracut-functions
%{dracutlibdir}/dracut-logger
%{dracutlibdir}/dracut-initramfs-restore
%config(noreplace) /etc/dracut.conf
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} > 6
%config /etc/dracut.conf.d/01-dist.conf
@@ -232,6 +239,7 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/10i18n
%{dracutlibdir}/modules.d/10rpmversion
%{dracutlibdir}/modules.d/30convertfs
%{dracutlibdir}/modules.d/45url-lib
%{dracutlibdir}/modules.d/50plymouth
%{dracutlibdir}/modules.d/90btrfs
%{dracutlibdir}/modules.d/90crypt
@@ -262,10 +270,15 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/98usrmount
%{dracutlibdir}/modules.d/99base
%{dracutlibdir}/modules.d/99fs-lib
%{dracutlibdir}/modules.d/99img-lib
%{dracutlibdir}/modules.d/99shutdown
%config(noreplace) /etc/logrotate.d/dracut_log
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
%dir %{_sharedstatedir}/initramfs
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
%{_unitdir}/*.service
%{_unitdir}/*/*.service
%endif
%files network
%defattr(-,root,root,0755)

View File

@@ -301,7 +301,7 @@ rd.live.overlay/
</para>
</listitem>
<listitem>
<para>Add &apos;&apos;rd.shell rd.debug&apos;&apos; to the kernel command line so that dracut shell commands are printed as they are executed
<para>Add &apos;&apos;rd.shell rd.debug log_buf_len=1M&apos;&apos; to the kernel command line so that dracut shell commands are printed as they are executed
</para>
</listitem>
<listitem>

View File

@@ -36,7 +36,7 @@ image="${1:-/boot/initramfs-$(uname -r).img}"
CAT=zcat
FILE_T=$(file "$image")
if echo "test"|xz|xz -dc --single-stream; then
if echo "test"|xz|xz -dc --single-stream >/dev/null 2>&1; then
XZ_SINGLE_STREAM="--single-stream"
fi

View File

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

View File

@@ -87,7 +87,6 @@ install() {
inst ${moddir}/console_init /lib/udev/console_init
inst_rules ${moddir}/10-console.rules
inst_hook cmdline 20 "${moddir}/parse-i18n.sh"
inst_hook cleanup 20 "${moddir}/i18n-cleanup.sh"
}
install_all_kbd() {

View File

@@ -76,6 +76,7 @@ install() {
inst "$moddir/ifup" "/sbin/ifup"
inst "$moddir/netroot" "/sbin/netroot"
inst "$moddir/dhclient-script" "/sbin/dhclient-script"
inst "$moddir/net-lib.sh" "/lib/net-lib.sh"
inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
inst_hook pre-udev 60 "$moddir/net-genrules.sh"

View File

@@ -0,0 +1,33 @@
#!/bin/sh
get_ip() {
local iface="$1" ip=""
ip=$(ip -o -f inet addr show $iface)
ip=${ip%%/*}
ip=${ip##* }
}
iface_for_remote_addr() {
set -- $(ip -o route get to $1)
echo $5
}
iface_for_mac() {
local interface="" mac="$(echo $1 | tr '[:upper:]' '[:lower:]')"
for interface in /sys/class/net/*; do
if [ $(cat $interface/address) = "$mac" ]; then
echo ${interface##*/}
fi
done
}
iface_has_link() {
local interface="$1" flags=""
[ -n "$interface" ] || return 2
interface="/sys/class/net/$interface"
[ -d "$interface" ] || return 2
flags=$(cat $interface/flags)
echo $(($flags|0x41)) > $interface/flags # 0x41: IFF_UP|IFF_RUNNING
[ "$(cat $interface/carrier)" = 1 ] || return 1
# XXX Do we need to reset the flags here? anaconda never bothered..
}

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# module-setup for url-lib
check() {
command -v curl >/dev/null || return 1
return 255
}
depends() {
echo network
return 0
}
install() {
inst "$moddir/url-lib.sh" "/lib/url-lib.sh"
dracut_install curl
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-certificates.crt; then
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
fi
}

118
modules.d/45url-lib/url-lib.sh Executable file
View File

@@ -0,0 +1,118 @@
#!/bin/sh
# url-lib.sh - functions for handling URLs (file fetching etc.)
#
# Authors:
# Will Woods <wwoods@redhat.com>
type mkuniqdir >/dev/null 2>&1 || . /lib/dracut-lib.sh
# fetch_url URL [OUTFILE]
# fetch the given URL to a locally-visible location.
# if OUTFILE is given, the URL will be fetched to that filename,
# overwriting it if present.
# If the URL is something mountable (e.g. nfs://) and no OUTFILE is given,
# the server will be left mounted until pre-pivot.
# the return values are as follows:
# 0: success
# 253: unknown error (file missing)
# 254: unhandled URL scheme / protocol
# 255: bad arguments / unparseable URLs
# other: fetch command failure (whatever curl/mount/etc return)
fetch_url() {
local url="$1" outloc="$2"
local handler="$(get_url_handler $url)"
[ -n "$handler" ] || return 254
[ -n "$url" ] || return 255
$handler "$url" "$outloc"
}
# get_url_handler URL
# returns the first HANDLERNAME corresponding to the URL's scheme
get_url_handler() {
local scheme="${1%%:*}" item=""
for item in $url_handler_map; do
[ "$scheme" = "${item%%:*}" ] && echo "${item#*:}" && return 0
done
return 1
}
# add_url_handler HANDLERNAME SCHEME [SCHEME...]
# associate the named handler with the named scheme(s).
add_url_handler() {
local handler="$1"; shift
local schemes="$@" scheme=""
set --
for scheme in $schemes; do
set -- "$@" "$scheme:$handler"
done
set -- $@ $url_handler_map # add new items to *front* of list
url_handler_map="$@"
}
### HTTP, HTTPS, FTP #################################################
export CURL_HOME="/run/initramfs/url-lib"
mkdir -p $CURL_HOME
curl_args="--location --retry 3 --fail --show-error"
curl_fetch_url() {
local url="$1" outloc="$2"
if [ -n "$outloc" ]; then
curl $curl_args --output "$outloc" "$url" || return $?
else
local outdir="$(mkuniqdir /tmp curl_fetch_url)"
local cwd="$(pwd)"
cd "$outdir"
curl $curl_args --remote-name "$url" || return $?
cd "$cwd"
outloc="$(echo $outdir/*)"
fi
[ -f "$outloc" ] || return 253
echo "$outloc"
}
add_url_handler curl_fetch_url http https ftp
set_http_header() {
echo "header = \"$1: $2\"" >> $CURL_HOME/.curlrc
}
### NFS ##############################################################
. /lib/nfs-lib.sh
nfs_already_mounted() {
local server="$1" path="$2" localdir="" s="" p=""
cat /proc/mounts | while read src mnt rest; do
splitsep ":" "$src" s p
if [ "$server" = "$s" ]; then
if [ "$path" = "$p" ]; then
echo $mnt
elif str_starts "$path" "$p"; then
echo $mnt/${path#$p/}
fi
fi
done
}
nfs_fetch_url() {
local url="$1" outloc="$2" nfs="" server="" path="" options=""
nfs_to_var "$url" || return 255
local filepath="${path%/*}" filename="${path##*/}" mntdir=""
# skip mount if server:/filepath is already mounted
mntdir=$(nfs_already_mounted $server $path)
if [ -z "$mntdir" ]; then
local mntdir="$(mkuniqdir /run nfs_mnt)"
mount_nfs $nfs:$server:$path${options:+:$options} $mntdir
# lazy unmount during pre-pivot hook
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l $mntdir
fi
if [ -z "$outloc" ]; then
outloc="$mntdir/$filename"
else
cp -f "$mntdir/$filename" "$outloc" || return $?
fi
[ -f "$outloc" ] || return 253
echo "$outloc"
}
add_url_handler nfs_fetch_url nfs nfs4

View File

@@ -46,7 +46,6 @@ install() {
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
inst_hook pre-trigger 10 "$moddir"/plymouth-pretrigger.sh
inst_hook cleanup 10 "$moddir"/plymouth-cleanup.sh
inst_hook emergency 50 "$moddir"/plymouth-emergency.sh
inst readlink
}

View File

@@ -1,5 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
rm -fr /usr/share/plymouth /usr/lib/plymouth /usr/lib64/plymouth /usr/share/pixmaps

View File

@@ -117,6 +117,7 @@ unset device luksname luksfile
# mark device as asked
>> /tmp/cryptroot-asked-$2
need_shutdown
udevsettle
exit 0

View File

@@ -40,3 +40,4 @@ else
done
fi
need_shutdown

View File

@@ -206,4 +206,6 @@ fi
ln -s /dev/mapper/live-rw /dev/root
printf '/bin/mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
need_shutdown
exit 0

View File

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

View File

@@ -31,7 +31,7 @@ installkernel() {
eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
}
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 ata_piix
hostonly='' instmods pcmcia firewire-ohci
hostonly='' instmods usb_storage sdhci sdhci-pci
@@ -46,9 +46,6 @@ installkernel() {
if ! [[ $hostonly ]]; then
if [[ -z $filesystems ]]; then
instmods '=fs'
# hardcoded list of exceptions
# to save a lot of space
rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
fi
else
inst_fs() {
@@ -75,7 +72,6 @@ install() {
inst_simple "$i"
done
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
inst_hook cleanup 20 "$moddir/kernel-cleanup.sh"
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
for _f in modules.builtin.bin modules.builtin; do

View File

@@ -1,41 +1,26 @@
#!/bin/bash
# livenetroot - fetch a live image from the network and run it
#
# TODO:
# * HTTPS: arg to use --no-check-certificate with https (boo)
# args for --certificate, --ca-certificate
# * NFS support?
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
[ -f /tmp/root.info ] && . /tmp/root.info
. /lib/url-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# args get passed from 40network/netroot
netroot=$2
netroot="$2"
liveurl="${netroot#livenet:}"
info "fetching $liveurl"
imgfile=$(fetch_url "$liveurl")
[ $? = 0 ] || die "failed to download live image: error $?"
liveurl=${netroot#livenet:}
if [ ${liveurl##*.} == "iso" ]; then
imgfile="/run/live.iso"
else
imgfile="/run/rootfs.img"
fi
case "$liveurl" in
http://*|https://*|ftp://*)
wget -O $imgfile "$liveurl"
;;
*) die "don't know how to handle URL: $liveurl" ;;
esac
[ $? == 0 ] || die "failed to download live image"
if [ ${imgfile##*.} == "iso" ]; then
# TODO: couldn't dmsquash-live-root handle this?
if [ ${imgfile##*.} = "iso" ]; then
root=$(losetup -f)
losetup $root $imgfile
else
root=$imgfile
fi
exec /sbin/dmsquash-live-root $root

View File

@@ -2,26 +2,15 @@
# module-setup.sh for livenet
check() {
# a live, host-only image doesn't really make a lot of sense
[[ $hostonly ]] && return 1
command -v wget >/dev/null || return 1
return 255
}
depends() {
echo network dmsquash-live
echo network url-lib dmsquash-live
return 0
}
install() {
dracut_install wget
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-certificates.crt; then
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
fi
inst_hook cmdline 29 "$moddir/parse-livenet.sh"
inst "$moddir/livenetroot" "/sbin/livenetroot"
}

View File

@@ -3,17 +3,20 @@
# root=live:[url-to-backing-file]
[ -z "$root" ] && root=$(getarg root=)
. /lib/url-lib.sh
str_starts $root "live:" && liveurl=$root
str_starts $liveurl "live:" || return
str_starts "$root" "live:" && liveurl="$root"
str_starts "$liveurl" "live:" || return
liveurl="${liveurl#live:}"
# setting netroot to "livenet:..." makes "livenetroot" get run after ifup
case "$liveurl" in
http://*|https://*|ftp://*)
netroot="livenet:$liveurl"
root="livenet" # quiet complaints from init
rootok=1 ;;
esac
if get_url_handler "$liveurl" >/dev/null; then
info "livenet: root image at $liveurl"
netroot="livenet:$liveurl"
root="livenet" # quiet complaints from init
rootok=1
else
info "livenet: no url handler for $liveurl"
fi
wait_for_dev /dev/root

View File

@@ -126,3 +126,5 @@ if [ "$lvmwritten" ]; then
rm -f /etc/lvm/lvm.conf
fi
unset lvmwritten
need_shutdown

View File

@@ -35,6 +35,6 @@ RUN+="/sbin/initqueue --timeout --name 50-mdraid_start --onetime --unique /sbin/
#
LABEL="md_incremental"
RUN+="/sbin/mdadm -I $env{DEVNAME}"
RUN+="/sbin/mdadm $env{rd_MD_OFFROOT} -I $env{DEVNAME}"
LABEL="md_end"

View File

@@ -4,8 +4,9 @@
_do_md_shutdown() {
local ret
local final=$1
local _offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
info "Disassembling mdraid devices."
mdadm -v --stop --scan
mdadm $_offroot -v --stop --scan
ret=$?
if [ "x$final" != "x" ]; then
info "cat /proc/mdstat"

View File

@@ -4,6 +4,7 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
containers=""
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
@@ -13,11 +14,11 @@ for md in /dev/md[0-9_]*; do
containers="$containers $md"
continue
fi
mdadm -S "$md" >/dev/null 2>&1
mdadm $_offroot -S "$md" >/dev/null 2>&1 || need_shutdown
done
for md in $containers; do
mdadm -S "$md" >/dev/null 2>&1
mdadm $_offroot -S "$md" >/dev/null 2>&1 || need_shutdown
done
unset containers udevinfo
unset containers udevinfo _offroot

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
if getargbool 0 rd.md.waitclean; then
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
containers=""
for md in /dev/md[0-9_]*; do
@@ -14,13 +15,13 @@ if getargbool 0 rd.md.waitclean; then
continue
fi
info "Waiting for $md to become clean"
mdadm -W "$md" >/dev/null 2>&1
mdadm $_offroot -W "$md" >/dev/null 2>&1
done
for md in $containers; do
info "Waiting for $md to become clean"
mdadm -W "$md" >/dev/null 2>&1
mdadm $_offroot -W "$md" >/dev/null 2>&1
done
unset containers udevinfo
unset containers udevinfo _offroot
fi

View File

@@ -7,6 +7,8 @@ _md_force_run() {
local _udevinfo
local _path_s
local _path_d
local _offroot
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
# try to force-run anything not running yet
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
@@ -20,7 +22,7 @@ _md_force_run() {
# inactive ?
[ "$(cat "$_path_s")" != "inactive" ] && continue
mdadm -R "$md" 2>&1 | vinfo
mdadm $_offroot -R "$md" 2>&1 | vinfo
# still inactive ?
[ "$(cat "$_path_s")" = "inactive" ] && continue
@@ -29,7 +31,7 @@ _md_force_run() {
[ ! -r "$_path_d" ] && continue
# workaround for mdmon bug
[ "$(cat "$_path_d")" -gt "0" ] && mdmon --takeover "$md"
[ "$(cat "$_path_d")" -gt "0" ] && mdmon $_offroot --takeover "$md"
done
}

View File

@@ -51,3 +51,5 @@ if ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF || getarg noddfmd || getarg nodmraid;
info "no MD RAID for SNIA ddf raids"
udevproperty rd_NO_MDDDF=1
fi
strstr "$(mdadm --help-options 2>&1)" offroot && udevproperty rd_MD_OFFROOT=--offroot

View File

@@ -5,6 +5,7 @@
if [ -e /etc/multipath.conf ]; then
modprobe dm-multipath
multipathd -B || multipathd
need_shutdown
else
rm /etc/udev/rules.d/??-multipath.rules 2>/dev/null
fi

View File

@@ -46,3 +46,5 @@ elif [ "$netdriver" = "bnx2x" ]; then
else
echo -n "$netif" > /sys/module/fcoe/parameters/create
fi
need_shutdown

View File

@@ -205,6 +205,8 @@ else
handle_netroot $iroot
fi
need_shutdown
# now we have a root filesystem somewhere in /dev/sda*
# let the normal block handler handle root=
exit 0

View File

@@ -107,4 +107,5 @@ fi
# NBD doesn't emit uevents when it gets connected, so kick it
echo change > /sys/block/nbd0/uevent
udevadm settle
need_shutdown
exit 0

View File

@@ -60,6 +60,7 @@ install() {
inst_hook pre-udev 99 "$moddir/nfs-start-rpc.sh"
inst_hook pre-pivot 99 "$moddir/nfsroot-cleanup.sh"
inst "$moddir/nfsroot" "/sbin/nfsroot"
inst "$moddir/nfs-lib.sh" "/lib/nfs-lib.sh"
mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs"
mkdir -m 0755 -p "$initdir/var/lib/rpcbind"
mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm"

139
modules.d/95nfs/nfs-lib.sh Executable file
View File

@@ -0,0 +1,139 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/net-lib.sh
# TODO: make these things not pollute the calling namespace
# nfs_to_var NFSROOT [NETIF]
# use NFSROOT to set $nfs, $server, $path, and $options.
# NFSROOT is something like: nfs[4]:<server>:/<path>[:<options>|,<options>]
# NETIF is used to get information from DHCP options, if needed.
nfs_to_var() {
# Unfortunately, there's multiple styles of nfs "URL" in use, so we need
# extra functions to parse them into $nfs, $server, $path, and $options.
# FIXME: local netif=${2:-$netif}?
case "$1" in
nfs://*) rfc2224_nfs_to_var "$1" ;;
nfs:*:*:/*) anaconda_nfs_to_var "$1" ;;
*) nfsroot_to_var "$1" ;;
esac
# if anything's missing, try to fill it in from DHCP options
if [ -z "$server" ] || [ -z "$path" ]; then nfsroot_from_dhcp $2; fi
# if there's a "%s" in the path, replace it with the hostname/IP
if strstr "$path" "%s"; then
local node=""
read node < /proc/sys/kernel/hostname
[ "$node" = "(none)" ] && node=$(get_ip $2)
path=${path%%%s*}$node${path#*%s} # replace only the first %s
fi
}
# root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
# root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
nfsroot_to_var() {
# strip nfs[4]:
local arg="$@:"
nfs="${arg%%:*}"
arg="${arg##$nfs:}"
# check if we have a server
if strstr "$arg" ':/*' ; then
server="${arg%%:/*}"
arg="/${arg##*:/}"
fi
path="${arg%%:*}"
# rest are options
options="${arg##$path}"
# strip leading ":"
options="${options##:}"
# strip ":"
options="${options%%:}"
# Does it really start with '/'?
[ -n "${path%%/*}" ] && path="error";
#Fix kernel legacy style separating path and options with ','
if [ "$path" != "${path#*,}" ] ; then
options=${path#*,}
path=${path%%,*}
fi
}
# RFC2224: nfs://<server>[:<port>]/<path>
rfc2224_nfs_to_var() {
nfs="nfs"
server="${1#nfs://}"
path="/${server#*/}"
server="${server%%/*}"
server="${server%%:}" # anaconda compat (nfs://<server>:/<path>)
local port="${server##*:}"
[ "$port" != "$server" ] && options="port=$port"
}
# Anaconda-style path with options: nfs:<options>:<server>:/<path>
# (without mount options, anaconda is the same as dracut)
anaconda_nfs_to_var() {
nfs="nfs"
options="${1#nfs:}"
server="${options#*:}"
server="${server%:/*}"
options="${options%%:*}"
path="/${1##*:/}"
}
# nfsroot_from_dhcp NETIF
# fill in missing server/path from DHCP options.
nfsroot_from_dhcp() {
local f
for f in /tmp/net.$1.override /tmp/dhclient.$1.dhcpopts; do
[ -f $f ] && . $f
done
[ -n "$new_root_path" ] && nfsroot_to_var "$nfs:$new_root_path"
[ -z "$path" ] && [ "$(getarg root=)" == "/dev/nfs" ] && path=/tftpboot/%s
[ -z "$server" ] && server=$new_dhcp_server_identifier
[ -z "$server" ] && server=$new_dhcp_next_server
[ -z "$server" ] && server=${new_root_path%%:*}
}
# Look through $options, fix "rw"/"ro", move "lock"/"nolock" to $nfslock
munge_nfs_options() {
local f="" flags="" nfsrw="ro" OLDIFS="$IFS"
IFS=,
for f in $options; do
case $f in
ro|rw) nfsrw=$f ;;
lock|nolock) nfslock=$f ;;
*) flags=${flags:+$flags,}$f ;;
esac
done
IFS="$OLDIFS"
# Override rw/ro if set on cmdline
getarg ro >/dev/null && nfsrw=ro
getarg rw >/dev/null && nfsrw=rw
options=$nfsrw${flags:+,$flags}
}
# mount_nfs NFSROOT MNTDIR [NETIF]
mount_nfs() {
local nfsroot="$1" mntdir="$2" netif="$3"
local nfs="" server="" path="" options=""
nfs_to_var $nfsroot $netif
munge_nfs_options
if [ "$nfs" = "nfs4" ]; then
options=$options${nfslock+,$nfslock}
else
# NFSv{2,3} doesn't support using locks as it requires a helper to
# transfer the rpcbind state to the new root
[ "$nfslock" = "lock" ] \
&& warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
options=$options,nolock
fi
mount -t $nfs -o$options $server:$path $mntdir
}

View File

@@ -3,17 +3,9 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/nfs-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Huh? Empty $1?
[ -z "$1" ] && exit 1
# Huh? Empty $2?
[ -z "$2" ] && exit 1
# Huh? Empty $3?
[ -z "$3" ] && exit 1
[ "$#" = 3 ] || exit 1
# root is in the form root=nfs[4]:[server:]path[:options], either from
# cmdline or dhcp root-path
@@ -21,89 +13,14 @@ netif="$1"
root="$2"
NEWROOT="$3"
# Continue if nfs prefix
case "${root%%:*}" in
nfs|nfs4);;
*) return;;
esac
nfsroot_to_var $root
#Load other data that might provide info
[ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override
[ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
#Empty path means try dhcp root-path, this is ok here since parse-nfsroot.sh
#already takes care of nfs:... formatted root-path
[ -z "$path" ] && nfsroot_to_var $nfs:$new_root_path
#Empty path defaults to "/tftpboot/%s" only in nfsroot.txt legacy mode
[ -z "$path" ] && [ "$(getarg root=)" = "/dev/nfs" ] && path="/tftpboot/%s"
if [ -z "$server" ] ; then
# XXX new_dhcp_next_server is unconfirmed this is an assumption
for var in $srv $new_dhcp_server_identifier $new_dhcp_next_server $new_root_path '' ; do
[ -n "$var" ] && server=$var && break;
done
# XXX This blindly assumes that if new_root_path has to used that
# XXX it really can be used as server
server=${server%%:*}
fi
nfs_to_var $root $netif
[ -z "$server" ] && die "Required parameter 'server' is missing"
# Kernel replaces first %s with host name, and falls back to the ip address
# if it isn't set. Only the first %s is substituted.
if [ "${path#*%s}" != "$path" ]; then
ip=$(ip -o -f inet addr show $netif)
ip=${ip%%/*}
ip=${ip##* }
read node < /proc/sys/kernel/hostname
[ "$node" = "(none)" ] && node=$ip
path=${path%%%s*}$node${path#*%s}
fi
# Look through the options and remove rw/locking options
OLDIFS="$IFS"
IFS=,
for f in $options ; do
[ "$f" = "ro" -o "$f" = "rw" ] && nfsrw=$f && continue
[ "$f" = "lock" -o "$f" = "nolock" ] && nfslock=$f && continue
flags=${flags:+$flags,}$f
done
IFS="$OLDIFS"
options=$flags
# Override rw/ro if set on cmdline
getarg ro && nfsrw=ro
getarg rw && nfsrw=rw
# Default to ro if unset
[ -z "$nfsrw" ] && nfsrw=ro
options=${options:+$options,}$nfsrw
if [ "$nfs" = "nfs4" ]; then
# XXX Should we loop here?
mount -t nfs4 -o$options${nfslock+,$nfslock} \
$server:$path $NEWROOT \
&& { [ -e /dev/root ] || >/dev/root ; }
else
# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
# the rpcbind state to the new root
[ "$nfslock" = "lock" ] && \
warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
# XXX Should we loop here?
{ mount -t nfs -o$options${options:+,}nolock,nfsvers=3 $server:$path $NEWROOT || \
mount -t nfs -o$options${options:+,}nolock,nfsvers=2 $server:$path $NEWROOT ; } \
&& { [ -e /dev/root ] || >/dev/root ; }
fi
mount_nfs $root $NEWROOT $netif && { [ -e /dev/root ] || >/dev/root ; }
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/nfs.sh
# force udevsettle to break
> $hookdir/initqueue/work
need_shutdown

View File

@@ -6,7 +6,7 @@ install() {
local _terminfodir
# terminfo bits make things work better if you fall into interactive mode
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -d ${_terminfodir} ] && break
[ -f ${_terminfodir}/l/linux ] && break
done
if [ -d ${_terminfodir} ]; then
@@ -14,7 +14,5 @@ install() {
inst_simple $f
done
fi
inst_hook cleanup 20 "${moddir}/terminfo-cleanup.sh"
}

View File

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

View File

@@ -7,7 +7,7 @@ check() {
}
depends() {
echo masterkey securityfs
echo masterkey securityfs selinux
return 0
}

View File

@@ -11,7 +11,17 @@ mount_usr()
# check, if we have to mount the /usr filesystem
while read _dev _mp _fs _opts _rest; do
if [ "$_mp" = "/usr" ]; then
echo "$_dev $NEWROOT/$_mp $_fs ${_opts} $_rest"
case "$_dev" in
LABEL=*)
_dev="$(echo $_dev | sed 's,/,\\x2f,g')"
_dev="/dev/disk/by-label/${_dev#LABEL=}"
;;
UUID=*)
_dev="${_dev#block:}"
_dev="/dev/disk/by-uuid/${_dev#UUID=}"
;;
esac
echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_rest"
_usr_found="1"
break
fi

View File

@@ -738,3 +738,7 @@ killproc() {
fi
done
}
need_shutdown() {
>/run/initramfs/.need_shutdown
}

View File

@@ -112,7 +112,7 @@ if [ "$RD_DEBUG" = "yes" ]; then
fi
if ! ismounted /dev; then
mount -t devtmpfs -o mode=0755,nosuid devtmpfs /dev >/dev/null 2>&1
mount -t devtmpfs -o mode=0755,nosuid devtmpfs /dev >/dev/null
fi
# prepare the /dev directory
@@ -123,17 +123,17 @@ fi
if ! ismounted /dev/pts; then
mkdir -m 0755 /dev/pts
mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null 2>&1
mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null
fi
if ! ismounted /dev/shm; then
mkdir -m 0755 /dev/shm
mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm >/dev/null 2>&1
mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm >/dev/null
fi
if ! ismounted /run; then
mkdir -m 0755 /newrun
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /newrun >/dev/null 2>&1
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /newrun >/dev/null
cp -a /run/* /newrun
mount --move /newrun /run
rm -fr /newrun
@@ -201,6 +201,7 @@ udevproperty "hookdir=$hookdir"
getarg 'rd.break=pre-trigger' 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
source_hook pre-trigger
udevadm control --reload >/dev/null 2>&1 || :
# then the rest
udevadm trigger --type=subsystems --action=add >/dev/null 2>&1
udevadm trigger --type=devices --action=add >/dev/null 2>&1

72
modules.d/99img-lib/img-lib.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/sh
# img-lib.sh: utilities for dealing with archives and filesystem images.
#
# TODO: identify/unpack rpm, deb?
# super-simple "file" that only identifies archives.
# works with stdin if $1 is not set.
det_archive() {
local bz="BZh" xz="$(echo -e '\xfd7zXZ')" gz="$(echo -e '\x1f\x8b')"
local headerblock="$(dd ${1:+if=$1} bs=262 count=1 2>/dev/null)"
case "$headerblock" in
$xz*) echo "xz" ;;
$gz*) echo "gzip" ;;
$bz*) echo "bzip2" ;;
07070*) echo "cpio" ;;
*ustar) echo "tar" ;;
esac
}
# determine filesystem type for a filesystem image
det_fs_img() {
local dev=$(losetup --find --show "$1") rv=""
det_fs $dev; rv=$?
losetup -d $dev
return $rv
}
# unpack_archive ARCHIVE OUTDIR
# unpack a (possibly compressed) cpio/tar archive
unpack_archive() {
local img="$1" outdir="$2" archiver="" decompr=""
local ft="$(det_archive $img)"
case "$ft" in
xz|gzip|bzip2) decompr="$decompr -dc" ;;
cpio|tar) decompr="cat";;
*) return 1 ;;
esac
ft="$($decompr $img | det_archive)"
case "$ft" in
cpio) archiver="cpio -iumd" ;;
tar) archiver="tar -xf -" ;;
*) return 2 ;;
esac
mkdir -p $outdir
( cd $outdir; $decompr | $archiver 2>/dev/null ) < $img
}
# unpack_fs FSIMAGE OUTDIR
# unpack a filesystem image
unpack_fs() {
local img="$1" outdir="$2" mnt="$(mkuniqdir /tmp unpack_fs.)"
mount -o loop $img $mnt || { rmdir $mnt; return 1; }
mkdir -p $outdir; outdir="$(cd $outdir; pwd)"
( cd $mnt; cp -a -t $outdir . )
umount $mnt
rmdir $mnt
}
# unpack an image file - compressed/uncompressed cpio/tar, filesystem, whatever
# unpack_img IMAGEFILE OUTDIR
unpack_img() {
local img="$1" outdir="$2"
[ -r "$img" ] || { warn "can't read img!"; return 1; }
[ -n "$outdir" ] || { warn "unpack_img: no output dir given"; return 1; }
if [ "$(det_img $img)" ]; then
unpack_archive "$@" || { warn "can't unpack archive file!"; return 1; }
else
unpack_fs "$@" || { warn "can't unpack filesystem image!"; return 1; }
fi
}

View File

@@ -0,0 +1,23 @@
#!/bin/bash
# module-setup for img-lib
check() {
for cmd in tar gzip dd; do
command -v $cmd >/dev/null || return 1
done
return 255
}
depends() {
return 0
}
install() {
# NOTE/TODO: we require bash, but I don't know how to specify that..
dracut_install tar gzip dd
dracut_install -o cpio xz
# TODO: make this conditional on a cmdline flag / config option
# dracut_install -o bzip2
inst "$moddir/img-lib.sh" "/lib/img-lib.sh"
}

View File

@@ -26,7 +26,6 @@ emergency_shell()
source_hook shutdown-emergency
echo
if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/console
echo "Dropping to debug shell."
echo
export PS1="$_rdshell_name:\${PWD}# "

View File

@@ -25,10 +25,15 @@ test_setup() {
# Create what will eventually be our root filesystem onto an overlay
(
initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \
mount dmesg ifconfig dhclient mkdir cp ping dhclient \
umount strace less
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep

View File

@@ -2,7 +2,7 @@
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1#*$2*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
command -v plymouth >/dev/null && plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
export TERM=linux
@@ -15,8 +15,10 @@ strstr "$CMDLINE" "rd.shell" && sh -i
echo "Powering down."
mount -n -o remount,ro /
#echo " rd.break=shutdown " >> /run/initramfs/etc/cmdline
echo " rd.debug=0 " >> /run/initramfs/etc/cmdline
if [ -d /run/initramfs/etc ]; then
echo " rd.debug=0 " >> /run/initramfs/etc/cmdline
fi
if [ -e /lib/systemd/systemd-shutdown ]; then
exec /lib/systemd/systemd-shutdown poweroff
exec /lib/systemd/systemd-shutdown poweroff
fi
poweroff -f

View File

@@ -26,16 +26,20 @@ test_setup() {
# Create what will eventually be our root filesystem onto an overlay
(
initdir=$TESTDIR/overlay/source
(mkdir -p "$initdir"; cd "$initdir"; mkdir -p dev sys proc etc var/run tmp run)
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
mount dmesg ifconfig dhclient mkdir cp ping dhclient
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst ./test-init /sbin/init
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep
dracut_install /lib/systemd/systemd-shutdown
inst ./test-init /sbin/init
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp run)
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)

View File

@@ -26,7 +26,11 @@ test_setup() {
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
mount dmesg ifconfig dhclient mkdir cp ping dhclient
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep

View File

@@ -1,5 +1,8 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
trap 'poweroff -f' EXIT
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
@@ -12,36 +15,28 @@ sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF
,400
,400
EOF
mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sda2 /dev/sda3 /dev/sda4
mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
echo -n test >keyfile
cryptsetup -q luksFormat /dev/md0 /keyfile
echo "The passphrase is test"
cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile && \
lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test && \
lvm vgcreate dracut /dev/mapper/dracut_crypt_test && \
lvm lvcreate -l 100%FREE -n root dracut && \
lvm vgchange -ay && \
mke2fs -L root /dev/dracut/root && \
mkdir -p /sysroot && \
mount /dev/dracut/root /sysroot && \
cp -a -t /sysroot /source/* && \
mkdir /sysroot/run && \
umount /sysroot && \
lvm lvchange -a n /dev/dracut/root && \
cryptsetup luksClose /dev/mapper/dracut_crypt_test && \
{ mdadm -W /dev/md0 || : ;} && \
mdadm /dev/md0 --fail /dev/sda2 --remove /dev/sda2 && \
{ mdadm -W /dev/md0 || : ;} && \
{
/sbin/mdadm --detail --export /dev/md0 |grep MD_UUID > /tmp/mduuid ;
. /tmp/mduuid;
} && \
{
echo "dracut-root-block-created"
echo MD_UUID=$MD_UUID
}> /dev/sda1
dd if=/dev/zero of=/dev/sda2
poweroff -f
set -e
cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile
lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
lvm vgcreate dracut /dev/mapper/dracut_crypt_test
lvm lvcreate -l 100%FREE -n root dracut
lvm vgchange -ay
mke2fs -L root /dev/dracut/root
mkdir -p /sysroot
mount /dev/dracut/root /sysroot
cp -a -t /sysroot /source/*
mkdir /sysroot/run
umount /sysroot
lvm lvchange -a n /dev/dracut/root
cryptsetup luksClose /dev/mapper/dracut_crypt_test
mdadm -W /dev/md0 || :
mdadm --detail --export /dev/md0 |grep MD_UUID > /tmp/mduuid
. /tmp/mduuid
{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID; } > /dev/sda1

View File

@@ -1,3 +1,3 @@
#!/bin/sh
getarg rd.shell || poweroff -f
getarg failme && poweroff -f
! getarg rd.break && getarg failme && poweroff -f

View File

@@ -1,11 +1,24 @@
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1#*$2*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
command -v plymouth >/dev/null && plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
stty sane
echo "made it to the rootfs! Powering down."
echo "made it to the rootfs!"
strstr "$CMDLINE" "rd.shell" && sh -i
echo "Powering down."
mount -n -o remount,ro /
#echo " rd.break=shutdown " >> /run/initramfs/etc/cmdline
if [ -d /run/initramfs/etc ]; then
echo " rd.debug=0 " >> /run/initramfs/etc/cmdline
fi
if [ -e /lib/systemd/systemd-shutdown ]; then
exec /lib/systemd/systemd-shutdown poweroff
fi
poweroff -f

View File

@@ -5,11 +5,17 @@ KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
#DEBUGFAIL="rd.shell rd.break=pre-mount udev.log-priority=debug"
client_run() {
echo "CLIENT TEST START: $@"
cp --sparse=always $TESTDIR/disk2.img $TESTDIR/disk2.img.new
cp --sparse=always $TESTDIR/disk3.img $TESTDIR/disk3.img.new
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 -m 256M -nographic \
-hdc $TESTDIR/disk2.img.new \
-hdd $TESTDIR/disk3.img.new \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "$@ root=LABEL=root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \
-initrd $TESTDIR/initramfs.testing
@@ -29,24 +35,15 @@ test_run() {
client_run || return 1
# client_run rd.md.conf=0 || return 1
client_run rd.md.uuid=$MD_UUID rd.md.conf=0 || return 1
client_run rd.md.uuid=failme rd.md.conf=0 failme && return 1
client_run rd.lvm=0 failme && return 1
client_run rd.lvm.vg=failme failme && return 1
client_run rd.lvm.vg=dracut || return 1
# client_run rd.md.uuid=$MD_UUID rd.md.conf=0 || return 1
client_run rd.lvm.vg=dummy1 rd.lvm.vg=dracut rd.lvm.vg=dummy2 rd.lvm.conf=0 failme && return 1
# client_run rd.md.uuid=failme rd.md.conf=0 failme && return 1
client_run rd.md=0 failme && return 1
# client_run rd.md.uuid=dummy1 rd.md.uuid=$MD_UUID rd.md.uuid=dummy2 rd.md.conf=0 failme && return 1
client_run rd.lvm.lv=dracut/failme failme && return 1
client_run rd.lvm.lv=dracut/root || return 1
return 0
}
@@ -54,6 +51,9 @@ test_setup() {
# Create the blank file to use as a root filesystem
rm -f $TESTDIR/root.ext2
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=40
dd if=/dev/null of=$TESTDIR/disk1.img bs=1M seek=20
dd if=/dev/null of=$TESTDIR/disk2.img bs=1M seek=20
dd if=/dev/null of=$TESTDIR/disk3.img bs=1M seek=20
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
@@ -61,7 +61,11 @@ test_setup() {
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
mount dmesg ifconfig dhclient mkdir cp ping dhclient
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep
@@ -92,6 +96,9 @@ test_setup() {
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \
-hdb $TESTDIR/disk1.img \
-hdc $TESTDIR/disk2.img \
-hdd $TESTDIR/disk3.img \
-m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \

View File

@@ -62,7 +62,11 @@ test_setup() {
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
mount dmesg ifconfig dhclient mkdir cp ping dhclient
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep

View File

@@ -5,8 +5,8 @@ KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
test_run() {
DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
$testdir/run-qemu \
-hda $DISKIMAGE \
-m 256M -nographic \
@@ -18,6 +18,7 @@ test_run() {
test_setup() {
# Create the blank file to use as a root filesystem
DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
rm -f $DISKIMAGE
dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024
@@ -27,7 +28,11 @@ test_setup() {
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
mount dmesg ifconfig dhclient mkdir cp ping dhclient
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep

View File

@@ -42,8 +42,12 @@ test_setup() {
initdir=$TESTDIR/root-source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \
mount dmesg ifconfig dhclient mkdir cp ping dhclient \
umount strace less
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep syslinux isohybrid

View File

@@ -213,9 +213,13 @@ test_setup() {
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping exportfs \
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
type -P portmap >/dev/null && dracut_install portmap
type -P rpcbind >/dev/null && dracut_install rpcbind
[ -f /etc/netconfig ] && dracut_install /etc/netconfig
@@ -261,8 +265,11 @@ test_setup() {
(
. $basedir/dracut-functions
dracut_install sh shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux mount dmesg mkdir \
cp ping grep
mount dmesg mkdir cp ping grep
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst ./client-init /sbin/init
(
cd "$initdir"

View File

@@ -99,8 +99,11 @@ test_setup() {
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux mount dmesg mkdir \
cp ping grep
mount dmesg mkdir cp ping grep
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst ./client-init /sbin/init
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
@@ -172,10 +175,14 @@ test_setup() {
)
inst /etc/passwd /etc/passwd
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping \
dmesg mkdir cp ping \
modprobe tcpdump \
/etc/services sleep mount chmod
dracut_install /usr/sbin/iscsi-target
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
instmods iscsi_tcp crc32c ipv6
inst ./targets /etc/iscsi/targets
[ -f /etc/netconfig ] && dracut_install /etc/netconfig

View File

@@ -6,7 +6,7 @@ TEST_DESCRIPTION="root filesystem on NBD"
KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell rd.retry=10"
#DEBUGFAIL="rd.shell rd.retry=10 rd.break"
#SERIAL="udp:127.0.0.1:9999"
SERIAL="null"
@@ -59,7 +59,7 @@ client_test() {
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12340 \
-kernel /boot/vmlinuz-$KVERSION \
-append "$cmdline $DEBUGFAIL rd.debug rd.info ro quiet console=ttyS0,115200n81 selinux=0" \
-append "$cmdline $DEBUGFAIL rd.debug rd.info rd.retry=10 ro quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.testing
if [[ $? -ne 0 ]] || ! grep -m 1 -q nbd-OK $TESTDIR/flag.img; then
@@ -191,12 +191,19 @@ make_encrypted_root() {
# Create what will eventually be our root filesystem onto an overlay
(
initdir=$TESTDIR/overlay/source
mkdir -p "$initdir"
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux mount dmesg mkdir cp ping
mount dmesg mkdir cp ping
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst ./client-init /sbin/init
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -239,20 +246,22 @@ make_client_root() {
(
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
mkdir -p "$initdir"
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping
dmesg mkdir cp ping
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst ./client-init /sbin/init
(
cd "$initdir";
mkdir -p dev sys proc etc var/run tmp
)
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group
for i in /lib*/libnss_files**;do
inst_library $i
for i in /usr/lib*/libnss_files* /lib*/libnss_files*;do
[ -e "$i" ] || continue
inst $i
done
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)
@@ -271,23 +280,29 @@ make_server_root() {
(
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
mkdir -p "$initdir"
(
cd "$initdir";
mkdir -p dev sys proc etc var/run var/lib/dhcpd tmp
)
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping grep \
dmesg mkdir cp ping grep \
sleep nbd-server chmod
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
type -P dhcpd >/dev/null && dracut_install dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
inst ./server-init /sbin/init
inst ./hosts /etc/hosts
inst ./dhcpd.conf /etc/dhcpd.conf
(
cd "$initdir";
mkdir -p dev sys proc etc var/run var/lib/dhcpd tmp
)
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group
for i in /lib*/libnss_files**;do
inst_library $i
for i in /usr/lib*/libnss_files* /lib*/libnss_files*;do
[ -e "$i" ] || continue
inst $i
done
cp -a /etc/ld.so.conf* $initdir/etc

View File

@@ -132,9 +132,13 @@ test_setup() {
initdir=$TESTDIR/mnt
. $basedir/dracut-functions
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux dmesg mkdir cp ping exportfs \
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
type -P portmap >/dev/null && dracut_install portmap
type -P rpcbind >/dev/null && dracut_install rpcbind
[ -f /etc/netconfig ] && dracut_install /etc/netconfig
@@ -189,8 +193,12 @@ test_setup() {
(
. $basedir/dracut-functions
dracut_install sh shutdown poweroff stty cat ps ln ip \
/lib/terminfo/l/linux mount dmesg mkdir \
cp ping grep ls
mount dmesg mkdir \
cp ping grep ls
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst ./client-init /sbin/init
(
cd "$initdir"

View File

@@ -28,10 +28,9 @@ client_run() {
}
test_run() {
client_run rd.md.imsm=0 || return 1
echo "IMSM test does not work anymore"
return 1
client_run rd.md.imsm || return 1
return 0
client_run || return 1
client_run rd.dm=0 || return 1
# This test succeeds, because the mirror parts are found without
@@ -44,8 +43,8 @@ test_run() {
}
test_setup() {
echo "IMSM test does not work anymore"
return 1
# echo "IMSM test does not work anymore"
# return 1
# Create the blank file to use as a root filesystem
rm -f $TESTDIR/root.ext2
@@ -61,7 +60,11 @@ test_setup() {
initdir=$TESTDIR/overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
mount dmesg ifconfig dhclient mkdir cp ping dhclient
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep