LOG=/tmp/dhclient.$$.log
ERR=/tmp/network.$$.err
-PATH=$PATH:/sbin:/usr/sbin
-
-. /lib/dracut-lib
-
-getarg rdnetdebug && {
- exec >/tmp/dhclient.$interface.$$.out
- exec 2>>/tmp/dhclient.$interface.$$.out
- set -x
-}
log_err() {
# avoid the need for cat on the image
while read line; do echo " $line"; done < $LOG >> $ERR
}
-# Catch unlikely initial errors
-trap 'echo Errors preparing to configure $netif > $ERR; exit 0' EXIT
-
-netif=$interface
-ip=$new_ip_address
-mtu=$new_interface_mtu
-mask=$new_subnet_mask
-bcast=$new_broadcast_address
-gw=${new_routers%%,*}
-domain=$new_domain_name
-search=$new_domain_search
-namesrv=$new_domain_name_servers
-hostname=$new_host_name
-
-[ -f /tmp/net.$interface.override ] && . /tmp/net.$interface.override
-
-# save the offending command and let udev move on if we have an error
-trap 'log_err; exit 0' EXIT
-
run() {
CMD="$@"
"$@" >> $LOG 2>&1
}
setup_interface() {
- [ -n "$mtu" ] && {
+ ip=$new_ip_address
+ mtu=$new_interface_mtu
+ mask=$new_subnet_mask
+ bcast=$new_broadcast_address
+ gw=${new_routers%%,*}
+ domain=$new_domain_name
+ search=$new_domain_search
+ namesrv=$new_domain_name_servers
+ hostname=$new_host_name
+
+ [ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+
+ if [ -n "$mtu" ] ; then
run ip link set $netif down
run ip link set $netif mtu $mtu
run ip link set $netif up
- }
+ fi
run ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif
[ -n "$gw" ] && run ip route add default via $gw
- [ -n "${search}${domain}" -a -n "$namesrv" ] && {
+ if [ -n "${search}${domain}" -a -n "$namesrv" ] ; then
echo search $search $domain > /etc/resolv.conf
for s in $namesrv; do
echo nameserver $s >> /etc/resolv.conf
done
- }
- [ -e /tmp/hostname.set ] || {
+ fi
+ if [ ! -e /tmp/hostname.set ] ; then
[ -n "$hostname" ] && mknod /tmp/hostname.set p && run hostname $hostname
- }
+ fi
:
}
+PATH=$PATH:/sbin:/usr/sbin
+
+. /lib/dracut-lib
+
+if getarg rdnetdebug ; then
+ exec >/tmp/dhclient.$interface.$$.out
+ exec 2>>/tmp/dhclient.$interface.$$.out
+ set -x
+fi
+
+# Huh? Interface configured?
+[ -f "/tmp/net.$netif.up" ] && exit 0
+
+# save offending commands and let udev move on if we have an error
+trap 'log_err; exit 0' EXIT
+
+# We already need a set netif here
+netif=$interface
+
case $reason in
PREINIT)
run ip link set $netif up
setup_interface
set | while read line; do
[ "${line#new_}" = "$line" ] && continue
- echo "$line" >>/tmp/dhclient.$netif.dhcpopts
- done
+ echo "$line"
+ done >/tmp/dhclient.$netif.dhcpopts
>/tmp/net.$netif.up
echo online > /sys/class/net/$netif/uevent ;;
*) ;;
#!/bin/sh
-PATH=$PATH:/sbin:/usr/sbin
-
-. /lib/dracut-lib
-
-getarg rdnetdebug && {
- exec >/tmp/ifup.$1.$$.out
- exec 2>>/tmp/ifup.$1.$$.out
- set -x
-}
-
-netif=$1
-
-# bail immediately if the interface is already up
-# or we don't need the network
-[ -f "/tmp/net.$netif.up" ] && exit 0
-[ -f "/tmp/root.info" ] || exit 0
-. /tmp/root.info
-[ -z "$netroot" ] && exit 0
-
-# loopback is always handled the same way
-[ "$netif" = "lo" ] && {
- ip link set lo up
- ip addr add 127.0.0.1/8 dev lo
- >/tmp/net.$netif.up
- exit 0
-}
-
-# XXX need error handling like dhclient-script
-
die() {
echo $netif: "$@" 1>&2
exit 1
dhclient -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif
}
-ip_to_var() {
- local v=${1}:
- set --
- while [ -n "$v" ]; do
- set -- "$@" "${v%%:*}"
- v=${v#*:}
- done
+PATH=$PATH:/sbin:/usr/sbin
- unset ip srv gw mask hostname dev autoconf
- case $# in
- 0) autoconf=off ;;
- 1) autoconf=$1 ;;
- 2) dev=$1; autoconf=$2 ;;
- *) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7
- case $autoconf in
- ''|none|off) [ -n "$ip" ] && autoconf=static ;;
- esac
- esac
- [ -n "$dev" ] || dev=$netif
- [ -n "$autoconf" ] || autoconf=off
-}
+. /lib/dracut-lib
+
+if getarg rdnetdebug ; then
+ exec >/tmp/ifup.$1.$$.out
+ exec 2>>/tmp/ifup.$1.$$.out
+ set -x
+fi
+
+# Huh? No $1?
+[ -z "$1" ] && exit 1
+
+# $netif reads easier than $1
+netif=$1
+
+# bail immediately if the interface is already up
+# or we don't need the network
+[ -f "/tmp/net.$netif.up" ] && exit 0
+[ -f "/tmp/root.info" ] || exit 0
+. /tmp/root.info
+[ -z "$netroot" ] && exit 0
+
+# loopback is always handled the same way
+if [ "$netif" = "lo" ] ; then
+ ip link set lo up
+ ip addr add 127.0.0.1/8 dev lo
+ >/tmp/net.$netif.up
+ exit 0
+fi
+
+# XXX need error handling like dhclient-script
+# No ip lines default to dhcp
ip=$(getarg ip)
-if [ -z "$ip" ]; then
- do_dhcp;
-else
- # spin through the kernel command line, looking for ip= lines
- [ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
- for p in $CMDLINE; do
- [ -n "${p%ip=*}" ] && continue
- ip_to_var ${p#ip=}
+[ -z "$ip" ] && do_dhcp;
+
+# Specific configuration, spin through the kernel command line
+# looking for ip= lines
+[ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
+for p in $CMDLINE; do
+ [ -n "${p%ip=*}" ] && continue
+ ip_to_var ${p#ip=}
- # If this option isn't directed at our interface, skip it
- [ "$dev" = "$netif" ] || continue
-
- # Store config for later use
- for i in ip srv gw mask hostname; do
- eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
- done > /tmp/net.$netif.override
-
- case $autoconf in
- static) do_static ;;
- dhcp|on|any) do_dhcp ;;
- bootp|rarp|both) die "autoconfig type $autoconf is not supported" ;;
- ''|none|off) ;;
+ # If this option isn't directed at our interface, skip it
+ [ "$dev" = "$netif" ] || continue
+
+ # Store config for later use
+ for i in ip srv gw mask hostname; do
+ eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
+ done > /tmp/net.$netif.override
+
+ case $autoconf in
+ static) do_static ;;
+ dhcp|on|any) do_dhcp ;;
+ bootp|rarp|both) die "autoconfig type $autoconf is not supported" ;;
+ ''|none|off) ;;
esac
break
done
. /lib/dracut-lib
-getarg rdnetdebug && {
+if getarg rdnetdebug ; then
exec >/tmp/netroot.$1.$$.out
exec 2>>/tmp/netroot.$1.$$.out
set -x
-}
+fi
# Huh? Empty $1?
[ -z "$1" ] && exit 1
# Only try to configure from one network interface at a time
#
-[ "$NETROOT_LOCKED" ] || {
+if [ -z "$NETROOT_LOCKED" ] ; then
NETROOT_LOCKED=true
export NETROOT_LOCKED
exec flock -xo /tmp/netroot.lock -c "$0 $*"
exit 1
-}
+fi
# There's no sense in doing something if no (net)root info is available
# or root is already there
#!/bin/sh
+#
+# This implementation is incomplete: Discovery mode is not implemented and
+# the argument handling doesn't follow currently agreed formats. This is mainly
+# because rfc4173 does not say anything about iscsi_initiator but open-iscsi's
+# iscsistart needs this.
+#
. /lib/dracut-lib
set -x
fi
-# read static conf settings
-for conf in conf/conf.d/*; do
- [ -f ${conf} ] && . ${conf}
-done
-
# Huh? Empty $1?
[ -z "$1" ] && exit 1
netif="$1"
root="$2"
+# read static conf settings
+for conf in conf/conf.d/*; do
+ [ -f ${conf} ] && . ${conf}
+done
+
+modprobe iscsi_tcp
+modprobe crc32c
+
+if getarg iscsi_firmware ; then
+ iscsistart -b
+ exit 0
+fi
+
+# override conf settings by command line options
+arg=$(getarg iscsi_initiator)
+[ -n "$arg" ] && iscsi_initiator=$arg
+arg=$(getarg iscsi_target_name)
+[ -n "$arg" ] && iscsi_target_name=$arg
+arg=$(getarg iscsi_target_ip)
+[ -n "$arg" ] && iscsi_target_ip=$arg
+arg=$(getarg iscsi_target_port)
+[ -n "$arg" ] && iscsi_target_port=$arg
+arg=$(getarg iscsi_target_group)
+[ -n "$arg" ] && iscsi_target_group=$arg
+arg=$(getarg iscsi_username)
+[ -n "$arg" ] && iscsi_username=$arg
+arg=$(getarg iscsi_password)
+[ -n "$arg" ] && iscsi_password=$arg
+arg=$(getarg iscsi_in_username)
+[ -n "$arg" ] && iscsi_in_username=$arg
+arg=$(getarg iscsi_in_password)
+[ -n "$arg" ] && iscsi_in_password=$arg
if [ $root = ${root#iscsi:} ]; then
iroot=$(getarg iscsiroot)
iroot=${root#iscsi:}
fi
-if getarg iscsi_firmware >/dev/null; then
- modprobe iscsi_tcp
- modprobe crc32c
- iscsistart -b
-else
- # override conf settings by command line options
- arg=$(getarg iscsi_initiator)
- [ -n "$arg" ] && iscsi_initiator=$arg
- arg=$(getarg iscsi_initiator)
- [ -n "$arg" ] && iscsi_target_name=$arg
- arg=$(getarg iscsi_target_ip)
- [ -n "$arg" ] && iscsi_target_ip=$arg
- arg=$(getarg iscsi_target_port)
- [ -n "$arg" ] && iscsi_target_port=$arg
- arg=$(getarg iscsi_target_group)
- [ -n "$arg" ] && iscsi_target_group=$arg
- arg=$(getarg iscsi_username)
- [ -n "$arg" ] && iscsi_username=$arg
- arg=$(getarg iscsi_password)
- [ -n "$arg" ] && iscsi_password=$arg
- arg=$(getarg iscsi_in_username)
- [ -n "$arg" ] && iscsi_in_username=$arg
- arg=$(getarg iscsi_in_password)
- [ -n "$arg" ] && iscsi_in_password=$arg
-
-
- # override conf/commandline options by dhcp root_path
- OLDIFS="$IFS"
- IFS=:
- set $iroot
- iscsi_target_ip=$1; shift
- iscsi_protocol=$1; shift # ignored
- iscsi_target_port=$1; shift
- iscsi_lun=$1; shift
- iscsi_target_name=$*
- IFS="$OLDIFS"
-
- getarg ro && iscsirw=ro
- getarg rw && iscsirw=rw
- fsopts=${fsopts+$fsopts,}${iscsirw}
-
- modprobe iscsi_tcp
- modprobe crc32c
-
- if [ -z $iscsi_initiator ]; then
- [ -f /etc/initiatorname.iscsi ] && . /etc/initiatorname.iscsi
- [ -f /etc/iscsi/initiatorname.iscsi ] && . /etc/iscsi/initiatorname.iscsi
- iscsi_initiator=$InitiatorName
- fi
-
- if [ -z $iscsi_target_port ]; then
- iscsi_target_port=3260
- fi
-
- if [ -z $iscsi_target_group ]; then
- iscsi_target_group=1
- fi
-
- if [ -z $iscsi_initiator ]; then
- iscsi_initiator=$(iscsi-iname)
- fi
-
- echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
-
- # FIXME $iscsi_lun?? $iscsi_protocol??
-
- iscsistart -i $iscsi_initiator -t $iscsi_target_name \
- -g $iscsi_target_group -a $iscsi_target_ip \
- -p $iscsi_target_port \
- ${iscsi_username+-u $iscsi_username} \
- ${iscsi_password+-w $iscsi_password} \
- ${iscsi_in_username+-U $iscsi_in_username} \
- ${iscsi_in_password+-W $iscsi_in_password}
- # now we have a root filesystem somewhere in /dev/sda*
- # let the normal block handler handle root=
+# override conf/commandline options by dhcp root_path
+# FIXME this assumes that all values have been provided
+OLDIFS="$IFS"
+IFS=:
+set $iroot
+iscsi_target_ip=$1; shift
+iscsi_protocol=$1; shift # ignored
+iscsi_target_port=$1; shift
+iscsi_lun=$1; shift
+iscsi_target_name=$*
+IFS="$OLDIFS"
+
+# XXX is this needed?
+getarg ro && iscsirw=ro
+getarg rw && iscsirw=rw
+fsopts=${fsopts+$fsopts,}${iscsirw}
+
+if [ -z $iscsi_initiator ]; then
+ # XXX Where are these from?
+ [ -f /etc/initiatorname.iscsi ] && . /etc/initiatorname.iscsi
+ [ -f /etc/iscsi/initiatorname.iscsi ] && . /etc/iscsi/initiatorname.iscsi
+ iscsi_initiator=$InitiatorName
+
+ # XXX rfc3720 says 'SCSI Initiator Name: The iSCSI Initiator Name specifies
+ # the worldwide unique name of the initiator.' Could we use hostname/ip
+ # if missing?
+fi
+
+if [ -z $iscsi_target_port ]; then
+ iscsi_target_port=3260
+fi
+
+if [ -z $iscsi_target_group ]; then
+ iscsi_target_group=1
fi
+if [ -z $iscsi_initiator ]; then
+ # XXX is this correct?
+ iscsi_initiator=$(iscsi-iname)
+fi
+
+echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
+
+# FIXME $iscsi_lun?? $iscsi_protocol??
+
+iscsistart -i $iscsi_initiator -t $iscsi_target_name \
+ -g $iscsi_target_group -a $iscsi_target_ip \
+ -p $iscsi_target_port \
+ ${iscsi_username+-u $iscsi_username} \
+ ${iscsi_password+-w $iscsi_password} \
+ ${iscsi_in_username+-U $iscsi_in_username} \
+ ${iscsi_in_password+-W $iscsi_in_password}
+
+# now we have a root filesystem somewhere in /dev/sda*
+# let the normal block handler handle root=
exit 0
# XXX needs error handling like ifup/dhclient-script
-getarg rdnetdebug && {
+if getarg rdnetdebug ; then
exec > /tmp/nfsroot.$1.$$.out
exec 2>> /tmp/nfsroot.$1.$$.out
set -x
-}
+fi
# Huh? Empty $1?
[ -z "$1" ] && exit 1
nfspath=${nfspath%%%s*}$node${nfspath#*%s}
fi
-# look through the flags and see if any are overridden by the command line
+# Look through the flags and see if any are overridden by the command line
# Append a , so we know we terminate
flags=${flags},
while [ -n "$flags" ]; do
nfsflags=${nfsflags+$nfsflags,}$f
done
+# Override rw/ro if set on cmdline
getarg ro && nfsrw=ro
getarg rw && nfsrw=rw
nfsflags=${nfsflags+$nfsflags,}${nfsrw}
incol2 /proc/filesystems nfs || modprobe nfs || exit 1
incol2 /proc/filesystems nfs4 || modprobe nfs || exit 1
-# XXX don't forget to move /var/lib/nfs/rpc_pipefs to new /
-
# Start rpcbind or rpcbind
-# XXX occasionally saw 'rpcbind: fork failed: No such device' -- why?
+# FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
[ -x /sbin/portmap ] && [ -z "$(pidof portmap)" ] && portmap
[ -x /sbin/rpcbind ] && [ -z "$(pidof rpcbind)" ] && rpcbind
-# XXX should I do rpc.idmapd here, or wait and start in the new root
-# XXX waiting assumes root can read everything it needs right up until
-# XXX we start it...
-
-# XXX really, want to retry in a loop I think, but not here...
-
if [ "$nfsver" = "nfs4" ]; then
- [ -n "$(pidof rpc.statd)" ] || rpc.statd
+ # Start rpc.statd as mount won't let us use locks on a NFSv4
+ # filesystem without talking to it. NFSv4 does locks internally,
+ # rpc.lockd isn't needed
+ [ -z "$(pidof rpc.statd)" ] && rpc.statd
# XXX really needed? Do we need non-root users before we start it in
# XXX the real root image?
rpc.idmapd
fi
- # NFSv4 does locks internally
+ # XXX Should we loop here?
exec mount -t nfs4 -o${nfsflags}${nfslock+,$nfslock} \
$nfsserver:$nfspath $NEWROOT
fi
# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
# the rpcbind state to the new root
-#
[ -z "$nfslock" -o "$nfslock" = "lock" ] &&
- echo "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
+ echo "Warning: Locks unsupported on NFSv{2,3}, using nolock" 1>&2
+
+# XXX Should we loop here?
exec mount -t nfs -onolock,$nfsflags $nfsserver:$nfspath $NEWROOT