summaryrefslogtreecommitdiffstats
path: root/modules.d/95znet/module-setup.sh
blob: 95164bba64f07d13db2269c4f5e538b02876da6c (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
#!/bin/bash

# called by dracut
check() {
    arch=${DRACUT_ARCH:-$(uname -m)}
    [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1

    require_binaries grep sed seq readlink chzdev || return 1

    return 0
}

# called by dracut
depends() {
    echo bash
    return 0
}

# called by dracut
installkernel() {
    instmods ctcm lcs qeth qeth_l2 qeth_l3
}

# called by dracut
install() {
    inst_hook cmdline 30 "$moddir/parse-ccw.sh"
    inst_multiple grep sed seq readlink chzdev
    if [[ $hostonly ]]; then
        local _tempfile
        _tempfile=$(mktemp --tmpdir="${DRACUT_TMPDIR}" dracut-zdev.XXXXXX)
        {
            chzdev qeth --export - --configured --persistent --quiet --type
            chzdev lcs --export - --configured --persistent --quiet --type
            chzdev ctc --export - --configured --persistent --quiet --type
        } 2> /dev/null > "$_tempfile"
        ddebug < "$_tempfile"
        chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \
            --yes --no-root-update --force 2>&1 | ddebug
        lszdev --configured --persistent --info \
            --base "/etc=$initdir/etc" 2>&1 | ddebug
        rm -f "$_tempfile"
        # these are purely generated udev rules so we have to glob expand
        # within $initdir and strip the $initdir prefix for mark_hostonly
        local -a _array
        # shellcheck disable=SC2155
        local _nullglob=$(shopt -p nullglob)
        shopt -u nullglob
        # shellcheck disable=SC2086
        readarray -t _array < <(
            ls -1 $initdir/etc/udev/rules.d/41-*.rules 2> /dev/null
        )
        [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}"
        # shellcheck disable=SC2086
        readarray -t _array < <(
            ls -1 $initdir/etc/modprobe.d/s390x-*.conf 2> /dev/null
        )
        [[ ${#_array[@]} -gt 0 ]] && mark_hostonly "${_array[@]#$initdir}"
        $_nullglob
    fi
}