]> git.ipfire.org Git - thirdparty/dracut.git/blame - modules.d/95iscsi/module-setup.sh
network/net-lib.sh: fix ibft interface configuration
[thirdparty/dracut.git] / modules.d / 95iscsi / module-setup.sh
CommitLineData
95d2dabc
HH
1#!/bin/bash
2# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3# ex: ts=8 sw=4 sts=4 et filetype=sh
4
5check() {
29b10e65 6 local _rootdev
95d2dabc
HH
7 # If our prerequisites are not met, fail anyways.
8 type -P iscsistart hostname iscsi-iname >/dev/null || return 1
9
10 # If hostonly was requested, fail the check if we are not actually
11 # booting from root.
12
b093aa2d 13 is_iscsi() {
83e0dc7a 14 local _dev=$1
cb08b013 15
b093aa2d
HH
16 [[ -L "/sys/dev/block/$_dev" ]] || return
17 cd "$(readlink -f "/sys/dev/block/$_dev")"
95d2dabc
HH
18 until [[ -d sys || -d iscsi_session ]]; do
19 cd ..
20 done
21 [[ -d iscsi_session ]]
b093aa2d 22 }
95d2dabc 23
7f347723 24 [[ $hostonly ]] || [[ $mount_needs ]] && {
b093aa2d 25 pushd . >/dev/null
83e0dc7a 26 for_each_host_dev_and_slaves is_iscsi || return 1
b093aa2d 27 popd >/dev/null
95d2dabc
HH
28 }
29 return 0
30}
31
32depends() {
33 echo network rootfs-block
34}
35
36installkernel() {
4f9f76cd
HH
37 local _arch=$(uname -m)
38
ecf9496d 39 instmods iscsi_tcp iscsi_ibft crc32c bnx2i iscsi_boot_sysfs qla4xxx cxgb3i cxgb4i be2iscsi
881eda69 40 iscsi_module_filter() {
9c2a1d0d
HH
41 local _funcs='iscsi_register_transport'
42 # subfunctions inherit following FDs
43 local _merge=8 _side2=9
44 function bmf1() {
45 local _f
46 while read _f; do
47 case "$_f" in
48 *.ko) [[ $(< $_f) =~ $_funcs ]] && echo "$_f" ;;
49 *.ko.gz) [[ $(gzip -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
50 *.ko.xz) [[ $(xz -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
51 esac
52 done
53 return 0
54 }
55
56 function rotor() {
57 local _f1 _f2
58 while read _f1; do
59 echo "$_f1"
60 if read _f2; then
61 echo "$_f2" 1>&${_side2}
62 fi
63 done | bmf1 1>&${_merge}
64 return 0
65 }
66 # Use two parallel streams to filter alternating modules.
67 set +x
68 eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
69 [[ $debug ]] && set -x
70 return 0
7c188029 71 }
9c2a1d0d 72
4f9f76cd 73 { find_kernel_modules_by_path drivers/scsi; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/scsi; fi;} \
881eda69 74 | iscsi_module_filter | instmods
95d2dabc
HH
75}
76
77install() {
af119460
HH
78 inst_multiple umount iscsistart hostname iscsi-iname
79 inst_multiple -o iscsiuio
95d2dabc 80 inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
eef7649e 81 inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
552ecca6 82 inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
0a5fd0dc
HH
83 if ! dracut_module_included "systemd"; then
84 inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
85 fi
41eba87b 86 dracut_need_initqueue
95d2dabc 87}