60 lines
1.5 KiB
Bash
Executable File
60 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
. /lib/dracut-lib
|
|
|
|
getarg rdnetdebug && {
|
|
exec >/tmp/netroot.$1.$$.out
|
|
exec 2>>/tmp/netroot.$1.$$.out
|
|
set -x
|
|
}
|
|
|
|
# Huh? Empty $1?
|
|
[ -z "$1" ] && exit 1
|
|
|
|
# Huh? No interface config?
|
|
[ ! -e /tmp/net.$1.up ] && exit 1
|
|
|
|
# Only try to configure from one network interface at a time
|
|
#
|
|
[ "$NETROOT_LOCKED" ] || {
|
|
NETROOT_LOCKED=true
|
|
export NETROOT_LOCKED
|
|
exec flock -xo /tmp/netroot.lock -c "$0 $*"
|
|
exit 1
|
|
}
|
|
|
|
# There's no sense in doing something if no (net)root info is available
|
|
# or root is already there
|
|
[ -e /tmp/root.info ] || exit 1
|
|
. /tmp/root.info
|
|
[ -d $NEWROOT/proc ] && exit 0
|
|
[ -z "$netroot" ] && exit 1
|
|
|
|
netif=$1
|
|
|
|
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
|
|
|
|
# Now, let the installed network root handlers figure this out
|
|
#
|
|
source_all netroot
|
|
|
|
# If we didn't get a handler set, then we're done
|
|
#
|
|
if [ -z "$handler" ]; then
|
|
# XXX informative error message?
|
|
exit 0
|
|
fi
|
|
|
|
# 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
|
|
[ -f /tmp/dhclient.$netif.lease ] && cp /tmp/dhclient.$netif.lease /tmp/net.$netif.lease
|
|
[ -f /tmp/dhclient.$netif.dhcpopts ] && cp /tmp/dhclient.$netif.dhcpopts /tmp/net.$netif.dhcpopts
|
|
[ -f /tmp/dhclient.$netif.override ] && cp /tmp/dhclient.$netif.override /tmp/net.$netif.override
|
|
|
|
# Save used netif for later use
|
|
echo $netif > /tmp/net.bootdev
|
|
fi
|
|
exit 0
|