]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/95iscsi/module-setup.sh
iscsi/module-setup.sh: fix host-only/mount checks
[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 . $dracutfunctions
14
15 [[ $debug ]] && set -x
16
17 is_iscsi() (
18 local _dev
19 _dev=$(get_maj_min $1)
20
21 [[ -L /sys/dev/block/$_dev ]] || return
22 cd "$(readlink -f /sys/dev/block/$_dev)"
23 until [[ -d sys || -d iscsi_session ]]; do
24 cd ..
25 done
26 [[ -d iscsi_session ]]
27 )
28
29 [[ $hostonly ]] || [[ $mount_needs ]] && {
30 for_each_host_dev_fs is_iscsi || return 1
31 }
32 return 0
33 }
34
35 depends() {
36 echo network rootfs-block
37 }
38
39 installkernel() {
40 instmods iscsi_tcp iscsi_ibft crc32c bnx2i iscsi_boot_sysfs qla4xxx cxgb3i cxgb4i be2iscsi
41 iscsi_module_filter() {
42 local _iscsifuncs='iscsi_register_transport'
43 local _f
44 while read _f; do case "$_f" in
45 *.ko) [[ $(< $_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
46 *.ko.gz) [[ $(gzip -dc <$_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
47 *.ko.xz) [[ $(xz -dc <$_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
48 esac
49 done
50 }
51 { find_kernel_modules_by_path drivers/scsi; find_kernel_modules_by_path drivers/s390/scsi; } \
52 | iscsi_module_filter | instmods
53 }
54
55 install() {
56 dracut_install umount
57 dracut_install -o iscsiuio
58 inst iscsistart
59 inst hostname
60 inst iscsi-iname
61 inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
62 inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
63 inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
64 inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
65 }