Skip to content

Commit

Permalink
fix(iscsi): replace sed call with bash internals
Browse files Browse the repository at this point in the history
This removes a fork/exec and additionally gives more information in debug logs.
  • Loading branch information
haraldh committed May 14, 2021
1 parent 8b2afb0 commit 66b920c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules.d/95iscsi/iscsiroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ handle_netroot() {
if strglobin "$iscsi_target_ip" '*:*:*' && ! strglobin "$iscsi_target_ip" '['; then
iscsi_target_ip="[$iscsi_target_ip]"
fi
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} | {
while read -r _ target _ || [ -n "$target" ]; do
echo "$target"
done
})
[ -z "$targets" ] && echo "Target discovery to $iscsi_target_ip:${iscsi_target_port:+$iscsi_target_port} failed with status $?" && exit 1

found=
Expand Down

0 comments on commit 66b920c

Please sign in to comment.