summaryrefslogtreecommitdiff
path: root/modules.d/95iscsi/module-setup.sh
blob: 078682c27519b8126e844a4299c04f5462111330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

check() {
    local _rootdev
    # If our prerequisites are not met, fail anyways.
    type -P iscsistart hostname iscsi-iname >/dev/null || return 1

    # If hostonly was requested, fail the check if we are not actually
    # booting from root.

    . $dracutfunctions

    [[ $debug ]] && set -x

    is_iscsi() (
        [[ -L /sys/dev/block/$1 ]] || return
        cd "$(readlink -f /sys/dev/block/$1)"
        until [[ -d sys || -d iscsi_session ]]; do
            cd ..
        done
        [[ -d iscsi_session ]]
    )

    [[ $hostonly ]] || [[ $mount_needs ]] && {
        _rootdev=$(find_root_block_device)
        if [[ $_rootdev ]]; then
            # root lives on a block device, so we can be more precise about
            # hostonly checking
            check_block_and_slaves is_iscsi "$_rootdev" || return 1
        else
            return 1
        fi
    }
    return 0
}

depends() {
    echo network rootfs-block
}

installkernel() {
    instmods iscsi_tcp iscsi_ibft crc32c bnx2i iscsi_boot_sysfs qla4xxx cxgb3i cxgb4i be2iscsi
    iscsi_module_filter() {
        local _iscsifuncs='iscsi_register_transport'
        local _f
        while read _f; do case "$_f" in
            *.ko)    [[ $(<         $_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
            *.ko.gz) [[ $(gzip -dc <$_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
            *.ko.xz) [[ $(xz -dc   <$_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
            esac
        done
    }
    { find_kernel_modules_by_path drivers/scsi; find_kernel_modules_by_path drivers/s390/scsi; } \
    | iscsi_module_filter  |  instmods
}

install() {
    dracut_install umount
    dracut_install -o iscsiuio
    inst iscsistart
    inst hostname
    inst iscsi-iname
    inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
    inst_hook pre-pivot 90 "$moddir/cleanup-iscsi.sh"
    inst "$moddir/iscsiroot" "/sbin/iscsiroot"
    inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
}