netroot and others: Style changes
Multiline conditionals ( && { ... } ) should use if, function declarations go to the top of the file, add/update comments and remove some unnecessary clutter.master
parent
447f044e8b
commit
580bb5417c
|
@ -4,15 +4,6 @@
|
||||||
|
|
||||||
LOG=/tmp/dhclient.$$.log
|
LOG=/tmp/dhclient.$$.log
|
||||||
ERR=/tmp/network.$$.err
|
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() {
|
log_err() {
|
||||||
# avoid the need for cat on the image
|
# avoid the need for cat on the image
|
||||||
|
@ -22,51 +13,63 @@ log_err() {
|
||||||
while read line; do echo " $line"; done < $LOG >> $ERR
|
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() {
|
run() {
|
||||||
CMD="$@"
|
CMD="$@"
|
||||||
"$@" >> $LOG 2>&1
|
"$@" >> $LOG 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_interface() {
|
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 down
|
||||||
run ip link set $netif mtu $mtu
|
run ip link set $netif mtu $mtu
|
||||||
run ip link set $netif up
|
run ip link set $netif up
|
||||||
}
|
fi
|
||||||
|
|
||||||
run ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif
|
run ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif
|
||||||
[ -n "$gw" ] && run ip route add default via $gw
|
[ -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
|
echo search $search $domain > /etc/resolv.conf
|
||||||
for s in $namesrv; do
|
for s in $namesrv; do
|
||||||
echo nameserver $s >> /etc/resolv.conf
|
echo nameserver $s >> /etc/resolv.conf
|
||||||
done
|
done
|
||||||
}
|
fi
|
||||||
[ -e /tmp/hostname.set ] || {
|
if [ ! -e /tmp/hostname.set ] ; then
|
||||||
[ -n "$hostname" ] && mknod /tmp/hostname.set p && run hostname $hostname
|
[ -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
|
case $reason in
|
||||||
PREINIT)
|
PREINIT)
|
||||||
run ip link set $netif up
|
run ip link set $netif up
|
||||||
|
@ -75,8 +78,8 @@ case $reason in
|
||||||
setup_interface
|
setup_interface
|
||||||
set | while read line; do
|
set | while read line; do
|
||||||
[ "${line#new_}" = "$line" ] && continue
|
[ "${line#new_}" = "$line" ] && continue
|
||||||
echo "$line" >>/tmp/dhclient.$netif.dhcpopts
|
echo "$line"
|
||||||
done
|
done >/tmp/dhclient.$netif.dhcpopts
|
||||||
>/tmp/net.$netif.up
|
>/tmp/net.$netif.up
|
||||||
echo online > /sys/class/net/$netif/uevent ;;
|
echo online > /sys/class/net/$netif/uevent ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
|
|
|
@ -1,34 +1,5 @@
|
||||||
#!/bin/sh
|
#!/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() {
|
die() {
|
||||||
echo $netif: "$@" 1>&2
|
echo $netif: "$@" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -66,35 +37,47 @@ do_dhcp() {
|
||||||
dhclient -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif
|
dhclient -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_to_var() {
|
PATH=$PATH:/sbin:/usr/sbin
|
||||||
local v=${1}:
|
|
||||||
set --
|
|
||||||
while [ -n "$v" ]; do
|
|
||||||
set -- "$@" "${v%%:*}"
|
|
||||||
v=${v#*:}
|
|
||||||
done
|
|
||||||
|
|
||||||
unset ip srv gw mask hostname dev autoconf
|
. /lib/dracut-lib
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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)
|
ip=$(getarg ip)
|
||||||
if [ -z "$ip" ]; then
|
[ -z "$ip" ] && do_dhcp;
|
||||||
do_dhcp;
|
|
||||||
else
|
# Specific configuration, spin through the kernel command line
|
||||||
# spin through the kernel command line, looking for ip= lines
|
# looking for ip= lines
|
||||||
[ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
|
[ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
|
||||||
for p in $CMDLINE; do
|
for p in $CMDLINE; do
|
||||||
[ -n "${p%ip=*}" ] && continue
|
[ -n "${p%ip=*}" ] && continue
|
||||||
ip_to_var ${p#ip=}
|
ip_to_var ${p#ip=}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
. /lib/dracut-lib
|
. /lib/dracut-lib
|
||||||
|
|
||||||
getarg rdnetdebug && {
|
if getarg rdnetdebug ; then
|
||||||
exec >/tmp/netroot.$1.$$.out
|
exec >/tmp/netroot.$1.$$.out
|
||||||
exec 2>>/tmp/netroot.$1.$$.out
|
exec 2>>/tmp/netroot.$1.$$.out
|
||||||
set -x
|
set -x
|
||||||
}
|
fi
|
||||||
|
|
||||||
# Huh? Empty $1?
|
# Huh? Empty $1?
|
||||||
[ -z "$1" ] && exit 1
|
[ -z "$1" ] && exit 1
|
||||||
|
@ -16,12 +16,12 @@ getarg rdnetdebug && {
|
||||||
|
|
||||||
# Only try to configure from one network interface at a time
|
# Only try to configure from one network interface at a time
|
||||||
#
|
#
|
||||||
[ "$NETROOT_LOCKED" ] || {
|
if [ -z "$NETROOT_LOCKED" ] ; then
|
||||||
NETROOT_LOCKED=true
|
NETROOT_LOCKED=true
|
||||||
export NETROOT_LOCKED
|
export NETROOT_LOCKED
|
||||||
exec flock -xo /tmp/netroot.lock -c "$0 $*"
|
exec flock -xo /tmp/netroot.lock -c "$0 $*"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
|
|
||||||
# There's no sense in doing something if no (net)root info is available
|
# There's no sense in doing something if no (net)root info is available
|
||||||
# or root is already there
|
# or root is already there
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
#!/bin/sh
|
#!/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
|
. /lib/dracut-lib
|
||||||
|
|
||||||
|
@ -12,11 +18,6 @@ if getarg rdnetdebug; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# read static conf settings
|
|
||||||
for conf in conf/conf.d/*; do
|
|
||||||
[ -f ${conf} ] && . ${conf}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Huh? Empty $1?
|
# Huh? Empty $1?
|
||||||
[ -z "$1" ] && exit 1
|
[ -z "$1" ] && exit 1
|
||||||
|
|
||||||
|
@ -31,6 +32,38 @@ done
|
||||||
netif="$1"
|
netif="$1"
|
||||||
root="$2"
|
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
|
if [ $root = ${root#iscsi:} ]; then
|
||||||
iroot=$(getarg iscsiroot)
|
iroot=$(getarg iscsiroot)
|
||||||
|
@ -38,81 +71,59 @@ else
|
||||||
iroot=${root#iscsi:}
|
iroot=${root#iscsi:}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if getarg iscsi_firmware >/dev/null; then
|
# override conf/commandline options by dhcp root_path
|
||||||
modprobe iscsi_tcp
|
# FIXME this assumes that all values have been provided
|
||||||
modprobe crc32c
|
OLDIFS="$IFS"
|
||||||
iscsistart -b
|
IFS=:
|
||||||
else
|
set $iroot
|
||||||
# override conf settings by command line options
|
iscsi_target_ip=$1; shift
|
||||||
arg=$(getarg iscsi_initiator)
|
iscsi_protocol=$1; shift # ignored
|
||||||
[ -n "$arg" ] && iscsi_initiator=$arg
|
iscsi_target_port=$1; shift
|
||||||
arg=$(getarg iscsi_initiator)
|
iscsi_lun=$1; shift
|
||||||
[ -n "$arg" ] && iscsi_target_name=$arg
|
iscsi_target_name=$*
|
||||||
arg=$(getarg iscsi_target_ip)
|
IFS="$OLDIFS"
|
||||||
[ -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
|
|
||||||
|
|
||||||
|
# XXX is this needed?
|
||||||
|
getarg ro && iscsirw=ro
|
||||||
|
getarg rw && iscsirw=rw
|
||||||
|
fsopts=${fsopts+$fsopts,}${iscsirw}
|
||||||
|
|
||||||
# override conf/commandline options by dhcp root_path
|
if [ -z $iscsi_initiator ]; then
|
||||||
OLDIFS="$IFS"
|
# XXX Where are these from?
|
||||||
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/initiatorname.iscsi ] && . /etc/initiatorname.iscsi
|
||||||
[ -f /etc/iscsi/initiatorname.iscsi ] && . /etc/iscsi/initiatorname.iscsi
|
[ -f /etc/iscsi/initiatorname.iscsi ] && . /etc/iscsi/initiatorname.iscsi
|
||||||
iscsi_initiator=$InitiatorName
|
iscsi_initiator=$InitiatorName
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z $iscsi_target_port ]; then
|
# 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
|
iscsi_target_port=3260
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $iscsi_target_group ]; then
|
if [ -z $iscsi_target_group ]; then
|
||||||
iscsi_target_group=1
|
iscsi_target_group=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $iscsi_initiator ]; then
|
if [ -z $iscsi_initiator ]; then
|
||||||
|
# XXX is this correct?
|
||||||
iscsi_initiator=$(iscsi-iname)
|
iscsi_initiator=$(iscsi-iname)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
|
echo "InitiatorName='$iscsi_initiator'" > /dev/.initiatorname.iscsi
|
||||||
|
|
||||||
# FIXME $iscsi_lun?? $iscsi_protocol??
|
# FIXME $iscsi_lun?? $iscsi_protocol??
|
||||||
|
|
||||||
iscsistart -i $iscsi_initiator -t $iscsi_target_name \
|
iscsistart -i $iscsi_initiator -t $iscsi_target_name \
|
||||||
-g $iscsi_target_group -a $iscsi_target_ip \
|
-g $iscsi_target_group -a $iscsi_target_ip \
|
||||||
-p $iscsi_target_port \
|
-p $iscsi_target_port \
|
||||||
${iscsi_username+-u $iscsi_username} \
|
${iscsi_username+-u $iscsi_username} \
|
||||||
${iscsi_password+-w $iscsi_password} \
|
${iscsi_password+-w $iscsi_password} \
|
||||||
${iscsi_in_username+-U $iscsi_in_username} \
|
${iscsi_in_username+-U $iscsi_in_username} \
|
||||||
${iscsi_in_password+-W $iscsi_in_password}
|
${iscsi_in_password+-W $iscsi_in_password}
|
||||||
# now we have a root filesystem somewhere in /dev/sda*
|
|
||||||
# let the normal block handler handle root=
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# now we have a root filesystem somewhere in /dev/sda*
|
||||||
|
# let the normal block handler handle root=
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -6,11 +6,11 @@ PATH=$PATH:/sbin:/usr/sbin
|
||||||
|
|
||||||
# XXX needs error handling like ifup/dhclient-script
|
# XXX needs error handling like ifup/dhclient-script
|
||||||
|
|
||||||
getarg rdnetdebug && {
|
if getarg rdnetdebug ; then
|
||||||
exec > /tmp/nfsroot.$1.$$.out
|
exec > /tmp/nfsroot.$1.$$.out
|
||||||
exec 2>> /tmp/nfsroot.$1.$$.out
|
exec 2>> /tmp/nfsroot.$1.$$.out
|
||||||
set -x
|
set -x
|
||||||
}
|
fi
|
||||||
|
|
||||||
# Huh? Empty $1?
|
# Huh? Empty $1?
|
||||||
[ -z "$1" ] && exit 1
|
[ -z "$1" ] && exit 1
|
||||||
|
@ -45,7 +45,7 @@ if [ "${nfspath#*%s}" != "$nfspath" ]; then
|
||||||
nfspath=${nfspath%%%s*}$node${nfspath#*%s}
|
nfspath=${nfspath%%%s*}$node${nfspath#*%s}
|
||||||
fi
|
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
|
# Append a , so we know we terminate
|
||||||
flags=${flags},
|
flags=${flags},
|
||||||
while [ -n "$flags" ]; do
|
while [ -n "$flags" ]; do
|
||||||
|
@ -65,6 +65,7 @@ while [ -n "$flags" ]; do
|
||||||
nfsflags=${nfsflags+$nfsflags,}$f
|
nfsflags=${nfsflags+$nfsflags,}$f
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Override rw/ro if set on cmdline
|
||||||
getarg ro && nfsrw=ro
|
getarg ro && nfsrw=ro
|
||||||
getarg rw && nfsrw=rw
|
getarg rw && nfsrw=rw
|
||||||
nfsflags=${nfsflags+$nfsflags,}${nfsrw}
|
nfsflags=${nfsflags+$nfsflags,}${nfsrw}
|
||||||
|
@ -73,21 +74,16 @@ nfsflags=${nfsflags+$nfsflags,}${nfsrw}
|
||||||
incol2 /proc/filesystems nfs || modprobe nfs || exit 1
|
incol2 /proc/filesystems nfs || modprobe nfs || exit 1
|
||||||
incol2 /proc/filesystems nfs4 || 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
|
# 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/portmap ] && [ -z "$(pidof portmap)" ] && portmap
|
||||||
[ -x /sbin/rpcbind ] && [ -z "$(pidof rpcbind)" ] && rpcbind
|
[ -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
|
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 really needed? Do we need non-root users before we start it in
|
||||||
# XXX the real root image?
|
# XXX the real root image?
|
||||||
|
@ -95,14 +91,15 @@ if [ "$nfsver" = "nfs4" ]; then
|
||||||
rpc.idmapd
|
rpc.idmapd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# NFSv4 does locks internally
|
# XXX Should we loop here?
|
||||||
exec mount -t nfs4 -o${nfsflags}${nfslock+,$nfslock} \
|
exec mount -t nfs4 -o${nfsflags}${nfslock+,$nfslock} \
|
||||||
$nfsserver:$nfspath $NEWROOT
|
$nfsserver:$nfspath $NEWROOT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
|
# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
|
||||||
# the rpcbind state to the new root
|
# the rpcbind state to the new root
|
||||||
#
|
|
||||||
[ -z "$nfslock" -o "$nfslock" = "lock" ] &&
|
[ -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
|
exec mount -t nfs -onolock,$nfsflags $nfsserver:$nfspath $NEWROOT
|
||||||
|
|
Loading…
Reference in New Issue