iscsi: remove $() where it does not fit

also simplify iscsiadm command to one call
master
Harald Hoyer 2018-08-13 10:56:53 +02:00
parent 746135dd1e
commit 6f0500ed4a
1 changed files with 18 additions and 15 deletions

View File

@ -208,28 +208,31 @@ handle_netroot()
echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > $hookdir/mount/01-$$-iscsi.sh echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > $hookdir/mount/01-$$-iscsi.sh
fi fi


### ToDo: Upstream calls systemd-run - Shall we, do we have to port this?

targets=$(iscsiadm -m discovery -t st -p $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} | sed 's/^.*iqn/iqn/') targets=$(iscsiadm -m discovery -t st -p $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} | sed 's/^.*iqn/iqn/')
[ -z "$targets" ] && echo "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && exit 1 [ -z "$targets" ] && echo "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && exit 1


for target in $iscsi_target_name; do for target in $iscsi_target_name; do
case "$targets" in case "$targets" in
*$target*) *$target*)
EXTRA=""
if [ -n "$iscsi_iface_name" ]; then if [ -n "$iscsi_iface_name" ]; then
$(iscsiadm -m iface -I $iscsi_iface_name --op=new) iscsiadm -m iface -I $iscsi_iface_name --op=new
[ -n "$iscsi_initiator" ] && $(iscsiadm -m iface -I $iscsi_iface_name --op=update --name=iface.initiatorname --value=$iscsi_initiator) EXTRA=" ${iscsi_netdev_name:+--name=iface.net_ifacename --value=$iscsi_netdev_name} "
[ -n "$iscsi_netdev_name" ] && $(iscsiadm -m iface -I $iscsi_iface_name --op=update --name=iface.net_ifacename --value=$iscsi_netdev_name) EXTRA="$EXTRA ${iscsi_initiator:+--name=iface.initiatorname --value=$iscsi_initiator} "
COMMAND="iscsiadm -m node -T $target -p $iscsi_target_ip${iscsi_target_port:+:$iscsi_target_port} -I $iscsi_iface_name --op=update"
else
COMMAND="iscsiadm -m node -T $target -p $iscsi_target_ip${iscsi_target_port:+:$iscsi_target_port} --op=update"
fi fi
$($COMMAND --name=node.startup --value=onboot) [ -n "$iscsi_param" ] && for param in $iscsi_param; do EXTRA="$EXTRA --name=${param%=*} --value=${param#*=}"; done
[ -n "$iscsi_username" ] && $($COMMAND --name=node.session.auth.username --value=$iscsi_username)
[ -n "$iscsi_password" ] && $($COMMAND --name=node.session.auth.password --value=$iscsi_password) iscsiadm -m node -T $target \
[ -n "$iscsi_in_username" ] && $($COMMAND --name=node.session.auth.username_in --value=$iscsi_in_username) ${iscsi_iface_name:+-I $iscsi_iface_name} \
[ -n "$iscsi_in_password" ] && $($COMMAND --name=node.session.auth.password_in --value=$iscsi_in_password) -p $iscsi_target_ip${iscsi_target_port:+:$iscsi_target_port} \
[ -n "$iscsi_param" ] && for param in $iscsi_param; do $($COMMAND --name=${param%=*} --value=${param#*=}); done --op=update \
--name=node.startup --value=onboot \
${iscsi_username:+ --name=node.session.auth.username --value=$iscsi_username} \
${iscsi_password:+ --name=node.session.auth.password --value=$iscsi_password} \
${iscsi_in_username:+--name=node.session.auth.username_in --value=$iscsi_in_username} \
${iscsi_in_password:+--name=node.session.auth.password_in --value=$iscsi_in_password} \
$EXTRA \
$NULL
;; ;;
*) *)
;; ;;