All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] a few patches
@ 2012-04-05 17:01 Will Woods
       [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Will Woods @ 2012-04-05 17:01 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

So here's 5 patches for dracut. Whee!

Patches 2, 3, and 4 are needed to fix a bunch of stuff blocking Fedora 17
releases - although I can add workarounds for the splitsep thing pretty
easily. 1 & 5 are nice but unnecessary.

Thanks!

-w

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] dracut-lib: add str_ends, to go along with str_starts
       [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-04-05 17:01   ` Will Woods
  2012-04-05 17:01   ` [PATCH 2/5] run setup_net at start of initqueue/online hook Will Woods
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Will Woods @ 2012-04-05 17:01 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 modules.d/99base/dracut-lib.sh |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index cb2e4dc..1ecd286 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -12,6 +12,11 @@ str_starts() {
     [ "${1#$2*}" != "$1" ]
 }
 
+# returns OK if $1 contains $2 at the end
+str_ends() {
+    [ "${1%*$2}" != "$1" ]
+}
+
 # replaces all occurrences of 'search' in 'str' with 'replacement'
 #
 # str_replace str search replacement
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] run setup_net at start of initqueue/online hook
       [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2012-04-05 17:01   ` [PATCH 1/5] dracut-lib: add str_ends, to go along with str_starts Will Woods
@ 2012-04-05 17:01   ` Will Woods
  2012-04-05 17:01   ` [PATCH 3/5] network: add save_netinfo, fix problems with nfs->NM takeover Will Woods
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Will Woods @ 2012-04-05 17:01 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

This makes sure the network is active and ready to use during the
initqueue/online hook.

It also makes it so you can run setup_net repeatedly without causing
error messages.
---
 modules.d/40network/net-genrules.sh |    3 +++
 modules.d/40network/net-lib.sh      |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh
index 84fd3ac..b3d5584 100755
--- a/modules.d/40network/net-genrules.sh
+++ b/modules.d/40network/net-genrules.sh
@@ -53,5 +53,8 @@ fix_bootif() {
 
     # Run the "online" hook
     printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n'
+    # And make sure we run setup_net at the start of the hook
+    echo '. /lib/net-lib.sh; setup_net $netif' > \
+            $hookdir/initqueue/online/05-setup_net.sh
 
 } > /etc/udev/rules.d/60-net.rules
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index 467c79f..a7abe81 100644
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -59,12 +59,14 @@ ifdown() {
     ip link set $netif down
     ip addr flush dev $netif
     echo "#empty" > /etc/resolv.conf
+    rm -f /tmp/net.$netif.did-setup
     # TODO: send "offline" uevent?
 }
 
 setup_net() {
     local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
     [ -e /tmp/net.$netif.up ] || return 1
+    [ -e /tmp/net.$netif.did-setup ] && return
     [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
     [ -z "$IFACES" ] && IFACES="$netif"
     for iface in $IFACES ; do
@@ -100,6 +102,7 @@ setup_net() {
     if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
         info "Resolving $dest via ARP on $netif failed"
     fi
+    > /tmp/net.$netif.did-setup
 }
 
 set_ifname() {
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] network: add save_netinfo, fix problems with nfs->NM takeover
       [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2012-04-05 17:01   ` [PATCH 1/5] dracut-lib: add str_ends, to go along with str_starts Will Woods
  2012-04-05 17:01   ` [PATCH 2/5] run setup_net at start of initqueue/online hook Will Woods
@ 2012-04-05 17:01   ` Will Woods
  2012-04-05 17:01   ` [PATCH 4/5] Make splitsep work as documented with less vars than fields Will Woods
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Will Woods @ 2012-04-05 17:01 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

For NetworkManager to properly take over a NFS-root system, we need to
have the interface name(s) in /tmp/net.ifaces and save the dhclient
lease. This lets the ifcfg module do its magic.

save_netinfo should properly write out /tmp/net.ifaces when needed, and
copies the dhclient files into place.
---
 modules.d/40network/net-lib.sh |   16 ++++++++++++++++
 modules.d/40network/netroot.sh |   10 ++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index a7abe81..c0f73da 100644
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -105,6 +105,22 @@ setup_net() {
     > /tmp/net.$netif.did-setup
 }
 
+save_netinfo() {
+    local netif="$1" IFACES="" f="" i=""
+    [ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
+    # Add $netif to the front of IFACES (if it's not there already).
+    set -- "$netif"
+    for i in $IFACES; do [ "$i" != "$netif" ] && set -- "$@" "$i"; done
+    IFACES="$*"
+    for i in $IFACES; do
+        for f in /tmp/dhclient.$i.*; do
+            [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.}
+        done
+    done
+    echo $IFACES > /tmp/.net.ifaces.new
+    mv /tmp/.net.ifaces.new /tmp/net.ifaces
+}
+
 set_ifname() {
     local name="$1" mac="$2" num=0 n=""
     # if it's already set, return the existing name
diff --git a/modules.d/40network/netroot.sh b/modules.d/40network/netroot.sh
index ac1c215..1bb62bb 100755
--- a/modules.d/40network/netroot.sh
+++ b/modules.d/40network/netroot.sh
@@ -84,14 +84,8 @@ source_hook netroot
 # Run the handler; don't store the root, it may change from device to device
 # XXX other variables to export?
 if $handler $netif $netroot $NEWROOT; then
-    # Network rootfs mount successful
-    for iface in $IFACES ; do
-        [ -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
-    done
-
-    # Save used netif for later use
-    [ ! -f /tmp/net.ifaces ] && echo $netif > /tmp/net.ifaces
+    # Network rootfs mount successful - save interface info for ifcfg etc.
+    save_netinfo $netif
 else
     warn "Mounting root via '$netif' failed"
     # If we're trying with multiple interfaces, put that one down.
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] Make splitsep work as documented with less vars than fields
       [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2012-04-05 17:01   ` [PATCH 3/5] network: add save_netinfo, fix problems with nfs->NM takeover Will Woods
@ 2012-04-05 17:01   ` Will Woods
  2012-04-05 17:01   ` [PATCH 5/5] shutdown: use emergency_shell from dracut-lib Will Woods
  2012-04-19 10:13   ` [PATCH] a few patches Harald Hoyer
  5 siblings, 0 replies; 7+ messages in thread
From: Will Woods @ 2012-04-05 17:01 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

According to its comment in dracut-lib.sh:

    splitsep ":" "one:all:the:rest" one two

should set two="all:the:rest". But there's no check to see if the
current field is the last field, so it just gets "all".
---
 modules.d/99base/dracut-lib.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 1ecd286..e10a34d 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -224,13 +224,14 @@ splitsep() {
     local sep="$1"; local str="$2"; shift 2
     local tmp
 
-    while [ -n "$str" -a -n "$*" ]; do
+    while [ -n "$str" -a "$#" -gt 1 ]; do
         tmp="${str%%$sep*}"
         eval "$1=${tmp}"
         str="${str#$tmp}"
         str="${str#$sep}"
         shift
     done
+    [ -n "$str" -a -n "$1" ] && eval "$1=$str"
 
     return 0
 }
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] shutdown: use emergency_shell from dracut-lib
       [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2012-04-05 17:01   ` [PATCH 4/5] Make splitsep work as documented with less vars than fields Will Woods
@ 2012-04-05 17:01   ` Will Woods
  2012-04-19 10:13   ` [PATCH] a few patches Harald Hoyer
  5 siblings, 0 replies; 7+ messages in thread
From: Will Woods @ 2012-04-05 17:01 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

---
 modules.d/99base/dracut-lib.sh   |   10 +++++---
 modules.d/99shutdown/shutdown.sh |   47 ++-----------------------------------
 2 files changed, 9 insertions(+), 48 deletions(-)

diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index e10a34d..a29d586 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -767,15 +767,17 @@ emergency_shell()
 {
     local _ctty
     set +e
+    local _rdshell_name="dracut" action="Boot" hook="emergency"
     if [ "$1" = "-n" ]; then
         _rdshell_name=$2
         shift 2
-    else
-        _rdshell_name=dracut
+    elif [ "$1" = "--shutdown" ]; then
+        _rdshell_name=$2; action="Shutdown"; hook="shutdown-emergency"
+        shift 2
     fi
     echo ; echo
     warn $@
-    source_hook emergency
+    source_hook "$hook"
     echo
     wait_for_loginit
     [ -e /run/initramfs/.die ] && exit 1
@@ -798,7 +800,7 @@ emergency_shell()
         strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
         setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
     else
-        warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
+        warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."
         # cause a kernel panic
         exit 1
     fi
diff --git a/modules.d/99shutdown/shutdown.sh b/modules.d/99shutdown/shutdown.sh
index 8817a4c..45345a4 100755
--- a/modules.d/99shutdown/shutdown.sh
+++ b/modules.d/99shutdown/shutdown.sh
@@ -12,49 +12,8 @@
 export TERM=linux
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
-emergency_shell()
-{
-    local _ctty
-    set +e
-    if [ "$1" = "-n" ]; then
-        _rdshell_name=$2
-        shift 2
-    else
-        _rdshell_name=dracut
-    fi
-    echo ; echo
-    warn $@
-    source_hook shutdown-emergency
-    echo
-    if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
-        echo "Dropping to debug shell."
-        echo
-        export PS1="$_rdshell_name:\${PWD}# "
-        [ -e /.profile ] || >/.profile
-
-        _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
-        if [ -z "$_ctty" ]; then
-            _ctty=console
-            while [ -f /sys/class/tty/$_ctty/active ]; do
-                _ctty=$(cat /sys/class/tty/$_ctty/active)
-                _ctty=${_ctty##* } # last one in the list
-            done
-            _ctty=/dev/$_ctty
-        fi
-        [ -c "$_ctty" ] || _ctty=/dev/tty1
-        strstr "$(setsid --help)" "control" && CTTY="-c"
-        setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
-    else
-        exec /lib/systemd/systemd-shutdown "$@"
-        warn "Shutdown has failed. To debug this issue add \"rdshell\" to the kernel command line."
-        # cause a kernel panic
-        exit 1
-    fi
-}
-
-trap "emergency_shell Signal caught!" 0
-
-getarg 'rd.break=pre-shutdown' && emergency_shell -n cmdline "Break before pre-shutdown"
+trap "emergency_shell --shutdown shutdown Signal caught!" 0
+getarg 'rd.break=pre-shutdown' && emergency_shell --shutdown pre-shutdown "Break before pre-shutdown"
 
 umount_a() {
     local _did_umount="n"
@@ -97,7 +56,7 @@ while _check_shutdown; do
 done
 _check_shutdown final
 
-getarg 'rd.break=shutdown' && emergency_shell -n cmdline "Break before shutdown"
+getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown"
 [ "$1" = "reboot" ] && reboot -f -d -n --no-wall
 [ "$1" = "poweroff" ] && poweroff -f -d -n --no-wall
 [ "$1" = "halt" ] && halt -f -d -n --no-wall
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] a few patches
       [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
                     ` (4 preceding siblings ...)
  2012-04-05 17:01   ` [PATCH 5/5] shutdown: use emergency_shell from dracut-lib Will Woods
@ 2012-04-19 10:13   ` Harald Hoyer
  5 siblings, 0 replies; 7+ messages in thread
From: Harald Hoyer @ 2012-04-19 10:13 UTC (permalink / raw)
  To: Will Woods; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

Am 05.04.2012 19:01, schrieb Will Woods:
> So here's 5 patches for dracut. Whee!
> 
> Patches 2, 3, and 4 are needed to fix a bunch of stuff blocking Fedora 17
> releases - although I can add workarounds for the splitsep thing pretty
> easily. 1 & 5 are nice but unnecessary.
> 
> Thanks!
> 
> -w

pushed

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-04-19 10:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-05 17:01 [PATCH] a few patches Will Woods
     [not found] ` <1333645299-16837-1-git-send-email-wwoods-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-05 17:01   ` [PATCH 1/5] dracut-lib: add str_ends, to go along with str_starts Will Woods
2012-04-05 17:01   ` [PATCH 2/5] run setup_net at start of initqueue/online hook Will Woods
2012-04-05 17:01   ` [PATCH 3/5] network: add save_netinfo, fix problems with nfs->NM takeover Will Woods
2012-04-05 17:01   ` [PATCH 4/5] Make splitsep work as documented with less vars than fields Will Woods
2012-04-05 17:01   ` [PATCH 5/5] shutdown: use emergency_shell from dracut-lib Will Woods
2012-04-19 10:13   ` [PATCH] a few patches Harald Hoyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.