Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib/dracut/modules..../95nbd
File: nbdroot.sh
#!/bin/sh
[0] Fix | Delete
[1] Fix | Delete
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
[2] Fix | Delete
[3] Fix | Delete
PATH=/usr/sbin:/usr/bin:/sbin:/bin
[4] Fix | Delete
[5] Fix | Delete
# Huh? Empty $1?
[6] Fix | Delete
[ -z "$1" ] && exit 1
[7] Fix | Delete
[8] Fix | Delete
# Huh? Empty $2?
[9] Fix | Delete
[ -z "$2" ] && exit 1
[10] Fix | Delete
[11] Fix | Delete
# Huh? Empty $3?
[12] Fix | Delete
[ -z "$3" ] && exit 1
[13] Fix | Delete
[14] Fix | Delete
# root is in the form root=nbd:srv:port[:fstype[:rootflags[:nbdopts]]]
[15] Fix | Delete
netif="$1"
[16] Fix | Delete
nroot="$2"
[17] Fix | Delete
NEWROOT="$3"
[18] Fix | Delete
[19] Fix | Delete
# If it's not nbd we don't continue
[20] Fix | Delete
[ "${nroot%%:*}" = "nbd" ] || return
[21] Fix | Delete
[22] Fix | Delete
nroot=${nroot#nbd:}
[23] Fix | Delete
nbdserver=${nroot%%:*}; nroot=${nroot#*:}
[24] Fix | Delete
nbdport=${nroot%%:*}; nroot=${nroot#*:}
[25] Fix | Delete
nbdfstype=${nroot%%:*}; nroot=${nroot#*:}
[26] Fix | Delete
nbdflags=${nroot%%:*}
[27] Fix | Delete
nbdopts=${nroot#*:}
[28] Fix | Delete
[29] Fix | Delete
if [ "$nbdopts" = "$nbdflags" ]; then
[30] Fix | Delete
unset nbdopts
[31] Fix | Delete
fi
[32] Fix | Delete
if [ "$nbdflags" = "$nbdfstype" ]; then
[33] Fix | Delete
unset nbdflags
[34] Fix | Delete
fi
[35] Fix | Delete
if [ "$nbdfstype" = "$nbdport" ]; then
[36] Fix | Delete
unset nbdfstype
[37] Fix | Delete
fi
[38] Fix | Delete
if [ -z "$nbdfstype" ]; then
[39] Fix | Delete
nbdfstype=auto
[40] Fix | Delete
fi
[41] Fix | Delete
[42] Fix | Delete
# look through the NBD options and pull out the ones that need to
[43] Fix | Delete
# go before the host etc. Append a ',' so we know we terminate the loop
[44] Fix | Delete
nbdopts=${nbdopts},
[45] Fix | Delete
while [ -n "$nbdopts" ]; do
[46] Fix | Delete
f=${nbdopts%%,*}
[47] Fix | Delete
nbdopts=${nbdopts#*,}
[48] Fix | Delete
if [ -z "$f" ]; then
[49] Fix | Delete
break
[50] Fix | Delete
fi
[51] Fix | Delete
if [ -z "${f%bs=*}" -o -z "${f%timeout=*}" ]; then
[52] Fix | Delete
preopts="$preopts $f"
[53] Fix | Delete
continue
[54] Fix | Delete
fi
[55] Fix | Delete
opts="$opts $f"
[56] Fix | Delete
done
[57] Fix | Delete
[58] Fix | Delete
# look through the flags and see if any are overridden by the command line
[59] Fix | Delete
nbdflags=${nbdflags},
[60] Fix | Delete
while [ -n "$nbdflags" ]; do
[61] Fix | Delete
f=${nbdflags%%,*}
[62] Fix | Delete
nbdflags=${nbdflags#*,}
[63] Fix | Delete
if [ -z "$f" ]; then
[64] Fix | Delete
break
[65] Fix | Delete
fi
[66] Fix | Delete
if [ "$f" = "ro" -o "$f" = "rw" ]; then
[67] Fix | Delete
nbdrw=$f
[68] Fix | Delete
continue
[69] Fix | Delete
fi
[70] Fix | Delete
fsopts=${fsopts:+$fsopts,}$f
[71] Fix | Delete
done
[72] Fix | Delete
[73] Fix | Delete
getarg ro && nbdrw=ro
[74] Fix | Delete
getarg rw && nbdrw=rw
[75] Fix | Delete
fsopts=${fsopts:+$fsopts,}${nbdrw}
[76] Fix | Delete
[77] Fix | Delete
# XXX better way to wait for the device to be made?
[78] Fix | Delete
i=0
[79] Fix | Delete
while [ ! -b /dev/nbd0 ]; do
[80] Fix | Delete
[ $i -ge 20 ] && exit 1
[81] Fix | Delete
if [ $UDEVVERSION -ge 143 ]; then
[82] Fix | Delete
udevadm settle --exit-if-exists=/dev/nbd0
[83] Fix | Delete
else
[84] Fix | Delete
sleep 0.1
[85] Fix | Delete
fi
[86] Fix | Delete
i=$(($i + 1))
[87] Fix | Delete
done
[88] Fix | Delete
[89] Fix | Delete
# If we didn't get a root= on the command line, then we need to
[90] Fix | Delete
# add the udev rules for mounting the nbd0 device
[91] Fix | Delete
if [ "$root" = "block:/dev/root" -o "$root" = "dhcp" ]; then
[92] Fix | Delete
printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-nbd-root.rules
[93] Fix | Delete
udevadm control --reload
[94] Fix | Delete
type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
[95] Fix | Delete
write_fs_tab /dev/root "$nbdfstype" "$fsopts"
[96] Fix | Delete
wait_for_dev -n /dev/root
[97] Fix | Delete
[98] Fix | Delete
if [ -z "$DRACUT_SYSTEMD" ]; then
[99] Fix | Delete
printf '/bin/mount %s\n' \
[100] Fix | Delete
"$NEWROOT" \
[101] Fix | Delete
> $hookdir/mount/01-$$-nbd.sh
[102] Fix | Delete
fi
[103] Fix | Delete
fi
[104] Fix | Delete
[105] Fix | Delete
if strstr "$(nbd-client --help 2>&1)" "systemd-mark"; then
[106] Fix | Delete
preopts="--systemd-mark $preopts"
[107] Fix | Delete
fi
[108] Fix | Delete
[109] Fix | Delete
if [ "$nbdport" -gt 0 ] 2>/dev/null; then
[110] Fix | Delete
if [ -z "$DRACUT_SYSTEMD" ]; then
[111] Fix | Delete
nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts || exit 1
[112] Fix | Delete
else
[113] Fix | Delete
systemd-run --no-block --service-type=forking --quiet \
[114] Fix | Delete
--description="nbd nbd0" \
[115] Fix | Delete
-p 'DefaultDependencies=no' \
[116] Fix | Delete
-p 'KillMode=none' \
[117] Fix | Delete
--unit="nbd0" -- nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts >/dev/null 2>&1 || exit 1
[118] Fix | Delete
fi
[119] Fix | Delete
else
[120] Fix | Delete
if [ -z "$DRACUT_SYSTEMD" ]; then
[121] Fix | Delete
nbd-client -name "$nbdport" "$nbdserver" /dev/nbd0 $preopts $opts || exit 1
[122] Fix | Delete
else
[123] Fix | Delete
systemd-run --no-block --service-type=forking --quiet \
[124] Fix | Delete
--description="nbd nbd0" \
[125] Fix | Delete
-p 'DefaultDependencies=no' \
[126] Fix | Delete
-p 'KillMode=none' \
[127] Fix | Delete
--unit="nbd0" -- nbd-client -name "$nbdport" "$nbdserver" /dev/nbd0 $preopts $opts >/dev/null 2>&1 || exit 1
[128] Fix | Delete
fi
[129] Fix | Delete
fi
[130] Fix | Delete
[131] Fix | Delete
# NBD doesn't emit uevents when it gets connected, so kick it
[132] Fix | Delete
echo change > /sys/block/nbd0/uevent
[133] Fix | Delete
udevadm settle
[134] Fix | Delete
need_shutdown
[135] Fix | Delete
exit 0
[136] Fix | Delete
[137] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function