Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib/dracut/modules..../95nbd
File: parse-nbdroot.sh
#!/bin/sh
[0] Fix | Delete
#
[1] Fix | Delete
# Preferred format:
[2] Fix | Delete
# root=nbd:srv:port/exportname[:fstype[:rootflags[:nbdopts]]]
[3] Fix | Delete
# [root=*] netroot=nbd:srv:port/exportname[:fstype[:rootflags[:nbdopts]]]
[4] Fix | Delete
#
[5] Fix | Delete
# nbdopts is a comma separated list of options to give to nbd-client
[6] Fix | Delete
#
[7] Fix | Delete
# root= takes precedence over netroot= if root=nbd[...]
[8] Fix | Delete
#
[9] Fix | Delete
[10] Fix | Delete
# Sadly there's no easy way to split ':' separated lines into variables
[11] Fix | Delete
netroot_to_var() {
[12] Fix | Delete
local v=${1}:
[13] Fix | Delete
set --
[14] Fix | Delete
while [ -n "$v" ]; do
[15] Fix | Delete
set -- "$@" "${v%%:*}"
[16] Fix | Delete
v=${v#*:}
[17] Fix | Delete
done
[18] Fix | Delete
[19] Fix | Delete
unset server port
[20] Fix | Delete
server=$2; port=$3;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
# This script is sourced, so root should be set. But let's be paranoid
[24] Fix | Delete
[ -z "$root" ] && root=$(getarg root=)
[25] Fix | Delete
[26] Fix | Delete
if [ -z "$netroot" ]; then
[27] Fix | Delete
for netroot in $(getargs netroot=); do
[28] Fix | Delete
[ "${netroot%%:*}" = "nbd" ] && break
[29] Fix | Delete
done
[30] Fix | Delete
[ "${netroot%%:*}" = "nbd" ] || unset netroot
[31] Fix | Delete
fi
[32] Fix | Delete
[33] Fix | Delete
# Root takes precedence over netroot
[34] Fix | Delete
if [ "${root%%:*}" = "nbd" ] ; then
[35] Fix | Delete
if [ -n "$netroot" ] ; then
[36] Fix | Delete
warn "root takes precedence over netroot. Ignoring netroot"
[37] Fix | Delete
[38] Fix | Delete
fi
[39] Fix | Delete
netroot=$root
[40] Fix | Delete
unset root
[41] Fix | Delete
fi
[42] Fix | Delete
[43] Fix | Delete
# If it's not nbd we don't continue
[44] Fix | Delete
[ "${netroot%%:*}" = "nbd" ] || return
[45] Fix | Delete
[46] Fix | Delete
[47] Fix | Delete
if [ -n "${DRACUT_SYSTEMD}" ] && [ "$root" = "dhcp" ]; then
[48] Fix | Delete
echo "root=$netroot" > /etc/cmdline.d/root.conf
[49] Fix | Delete
systemctl --no-block daemon-reload
[50] Fix | Delete
fi
[51] Fix | Delete
[52] Fix | Delete
# Check required arguments
[53] Fix | Delete
netroot_to_var $netroot
[54] Fix | Delete
[ -z "$server" ] && die "Argument server for nbdroot is missing"
[55] Fix | Delete
[ -z "$port" ] && die "Argument port for nbdroot is missing"
[56] Fix | Delete
[57] Fix | Delete
# NBD actually supported?
[58] Fix | Delete
incol2 /proc/devices nbd || modprobe nbd || die "nbdroot requested but kernel/initrd does not support nbd"
[59] Fix | Delete
[60] Fix | Delete
# Done, all good!
[61] Fix | Delete
rootok=1
[62] Fix | Delete
[63] Fix | Delete
# Shut up init error check
[64] Fix | Delete
if [ -z "$root" ]; then
[65] Fix | Delete
root=block:/dev/root
[66] Fix | Delete
wait_for_dev -n /dev/root
[67] Fix | Delete
fi
[68] Fix | Delete
[69] Fix | Delete
[70] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function