]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/95iscsi/module-setup.sh
dracut-functions: make local vars local and prefix with "_"
[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 [[ -L /sys/dev/block/$1 ]] || return
19 cd "$(readlink -f /sys/dev/block/$1)"
20 until [[ -d sys || -d iscsi_session ]]; do
21 cd ..
22 done
23 [[ -d iscsi_session ]]
24 )
25
26 [[ $hostonly ]] && {
27 _rootdev=$(find_root_block_device)
28 if [[ $_rootdev ]]; then
29 # root lives on a block device, so we can be more precise about
30 # hostonly checking
31 check_block_and_slaves is_iscsi "$_rootdev" || return 1
32 else
33 return 1
34 fi
35 }
36 return 0
37 }
38
39 depends() {
40 echo network rootfs-block
41 }
42
43 installkernel() {
44 instmods iscsi_tcp iscsi_ibft crc32c
45 iscsi_module_test() {
46 local _iscsifuncs='iscsi_register_transport'
47 fgrep -q "$_iscsifuncs" "$1"
48 }
49 instmods $(filter_kernel_modules iscsi_module_test)
50 }
51
52 install() {
53 dracut_install umount
54 inst iscsistart
55 inst hostname
56 inst iscsi-iname
57 inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
58 inst "$moddir/iscsiroot" "/sbin/iscsiroot"
59 inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
60 }