Browse Source

fix(nvmf): shellcheck for modules.d/95nvmf

master
Harald Hoyer 4 years ago committed by Harald Hoyer
parent
commit
c305877c58
  1. 0
      modules.d/95nvmf/.shchkdir
  2. 9
      modules.d/95nvmf/module-setup.sh
  3. 9
      modules.d/95nvmf/parse-nvmf-boot-connections.sh

0
modules.d/95nvmf/.shchkdir

9
modules.d/95nvmf/module-setup.sh

@ -29,7 +29,7 @@ check() {
pushd . > /dev/null pushd . > /dev/null
for_each_host_dev_and_slaves is_nvmf for_each_host_dev_and_slaves is_nvmf
local _is_nvmf=$? local _is_nvmf=$?
popd > /dev/null popd > /dev/null || exit
[[ $_is_nvmf == 0 ]] || return 255 [[ $_is_nvmf == 0 ]] || return 255
if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then
if [ ! -f /etc/nvme/discovery.conf ]; then if [ ! -f /etc/nvme/discovery.conf ]; then
@ -76,7 +76,7 @@ cmdline() {
done done


[ -z "$trtype" ] && return 0 [ -z "$trtype" ] && return 0
nvme list-subsys ${PWD##*/} | while read x dev trtype traddr host_traddr state ana; do nvme list-subsys "${PWD##*/}" | while read -r _ _ trtype traddr host_traddr _; do
[ "$trtype" != "${trtype#NQN}" ] && continue [ "$trtype" != "${trtype#NQN}" ] && continue
echo -n " nvmf.discover=$trtype,${traddr#traddr=},${host_traddr#host_traddr=}" echo -n " nvmf.discover=$trtype,${traddr#traddr=},${host_traddr#host_traddr=}"
done done
@ -94,14 +94,15 @@ cmdline() {
[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
pushd . > /dev/null pushd . > /dev/null
for_each_host_dev_and_slaves gen_nvmf_cmdline for_each_host_dev_and_slaves gen_nvmf_cmdline
popd > /dev/null popd > /dev/null || exit
} }
} }


# called by dracut # called by dracut
install() { install() {
if [[ $hostonly_cmdline == "yes" ]]; then if [[ $hostonly_cmdline == "yes" ]]; then
local _nvmf_args=$(cmdline) local _nvmf_args
_nvmf_args=$(cmdline)
[[ "$_nvmf_args" ]] && printf "%s" "$_nvmf_args" >> "${initdir}/etc/cmdline.d/95nvmf-args.conf" [[ "$_nvmf_args" ]] && printf "%s" "$_nvmf_args" >> "${initdir}/etc/cmdline.d/95nvmf-args.conf"
fi fi
inst_simple "/etc/nvme/hostnqn" inst_simple "/etc/nvme/hostnqn"

9
modules.d/95nvmf/parse-nvmf-boot-connections.sh

@ -32,7 +32,7 @@ validate_ip_conn() {
return 1 return 1
fi fi


local_address=$(ip -o route get to $traddr | sed -n 's/.*src \([0-9a-f.:]*\).*/\1/p') local_address=$(ip -o route get to "$traddr" | sed -n 's/.*src \([0-9a-f.:]*\).*/\1/p')


# confirm we got a local IP address # confirm we got a local IP address
if ! is_ip "$local_address"; then if ! is_ip "$local_address"; then
@ -40,7 +40,7 @@ validate_ip_conn() {
return 1 return 1
fi fi


ifname=$(ip -o route get to $local_address | sed -n 's/.*dev \([^ ]*\).*/\1/p') ifname=$(ip -o route get to "$local_address" | sed -n 's/.*dev \([^ ]*\).*/\1/p')


if ip l show "$ifname" > /dev/null 2>&1; then if ip l show "$ifname" > /dev/null 2>&1; then
warn "invalid network interface $ifname" warn "invalid network interface $ifname"
@ -61,7 +61,8 @@ parse_nvmf_discover() {
trsvcid=4420 trsvcid=4420
OLDIFS="$IFS" OLDIFS="$IFS"
IFS=, IFS=,
set $1 # shellcheck disable=SC2086
set -- $1
IFS="$OLDIFS" IFS="$OLDIFS"


case $# in case $# in
@ -133,7 +134,7 @@ done
if [ -f "/etc/nvme/discovery.conf" ]; then if [ -f "/etc/nvme/discovery.conf" ]; then
/sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all /sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
if [ "$trtype" = "tcp" ]; then if [ "$trtype" = "tcp" ]; then
> /tmp/net.$ifname.did-setup : > /tmp/net."$ifname".did-setup
fi fi
else else
# No nvme command line arguments present, try autodiscovery # No nvme command line arguments present, try autodiscovery

Loading…
Cancel
Save