]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/95iscsi/module-setup.sh
iscsi/iscsiroot.sh: do not mount manually in systemd mode
[thirdparty/dracut.git] / modules.d / 95iscsi / module-setup.sh
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
5 check() {
6 local _rootdev
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
13 is_iscsi() (
14 local _dev=$1
15
16 [[ -L /sys/dev/block/$_dev ]] || return
17 cd "$(readlink -f /sys/dev/block/$_dev)"
18 until [[ -d sys || -d iscsi_session ]]; do
19 cd ..
20 done
21 [[ -d iscsi_session ]]
22 )
23
24 [[ $hostonly ]] || [[ $mount_needs ]] && {
25 for_each_host_dev_and_slaves is_iscsi || return 1
26 }
27 return 0
28 }
29
30 depends() {
31 echo network rootfs-block
32 }
33
34 installkernel() {
35 local _arch=$(uname -m)
36
37 instmods iscsi_tcp iscsi_ibft crc32c bnx2i iscsi_boot_sysfs qla4xxx cxgb3i cxgb4i be2iscsi
38 iscsi_module_filter() {
39 local _funcs='iscsi_register_transport'
40 # subfunctions inherit following FDs
41 local _merge=8 _side2=9
42 function bmf1() {
43 local _f
44 while read _f; do
45 case "$_f" in
46 *.ko) [[ $(< $_f) =~ $_funcs ]] && echo "$_f" ;;
47 *.ko.gz) [[ $(gzip -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
48 *.ko.xz) [[ $(xz -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
49 esac
50 done
51 return 0
52 }
53
54 function rotor() {
55 local _f1 _f2
56 while read _f1; do
57 echo "$_f1"
58 if read _f2; then
59 echo "$_f2" 1>&${_side2}
60 fi
61 done | bmf1 1>&${_merge}
62 return 0
63 }
64 # Use two parallel streams to filter alternating modules.
65 set +x
66 eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
67 [[ $debug ]] && set -x
68 return 0
69 }
70
71 { find_kernel_modules_by_path drivers/scsi; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/scsi; fi;} \
72 | iscsi_module_filter | instmods
73 }
74
75 install() {
76 dracut_install umount iscsistart hostname iscsi-iname
77 dracut_install -o iscsiuio
78 inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
79 inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
80 inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
81 if ! dracut_module_included "systemd"; then
82 inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
83 fi
84 dracut_need_initqueue
85 }