File: module-setup.sh

package info (click to toggle)
dracut 109-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,872 kB
  • sloc: sh: 24,527; ansic: 5,234; makefile: 346; perl: 186; python: 48; javascript: 19
file content (101 lines) | stat: -rwxr-xr-x 3,873 bytes parent folder | download | duplicates (3)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

# called by dracut
check() {
    [[ $mount_needs ]] && return 1

    # If the binary(s) requirements are not fulfilled the module can't be installed
    require_binaries "$systemdutildir"/systemd || return 1

    return 0
}

# due to the dependencies below, this dracut module needs to be ordered later than systemd-initrd, systemd-ask-password and the crypt dracut modules

# called by dracut
depends() {
    local deps
    deps="systemd-initrd systemd-ask-password"

    # when systemd and crypt are both included
    # systemd-cryptsetup is mandatory dependency
    # see https://github.com/dracut-ng/dracut-ng/issues/563
    if dracut_module_included "crypt"; then
        module_check systemd-cryptsetup > /dev/null 2>&1
        if [[ $? == 255 ]]; then
            deps+=" systemd-cryptsetup"
        fi
    fi

    echo "$deps"
    return 0
}

# called by dracut
install() {
    inst_script "$moddir/dracut-emergency.sh" /usr/bin/dracut-emergency
    inst_simple "$moddir/emergency.service" "${systemdsystemunitdir}"/emergency.service
    inst_simple "$moddir/dracut-emergency.service" "${systemdsystemunitdir}"/dracut-emergency.service
    inst_simple "$moddir/emergency.service" "${systemdsystemunitdir}"/rescue.service

    ln_r "${systemdsystemunitdir}/initrd.target" "${systemdsystemunitdir}/default.target"

    inst_script "$moddir/dracut-cmdline.sh" /usr/bin/dracut-cmdline
    inst_script "$moddir/dracut-cmdline-ask.sh" /usr/bin/dracut-cmdline-ask
    inst_script "$moddir/dracut-pre-udev.sh" /usr/bin/dracut-pre-udev
    inst_script "$moddir/dracut-pre-trigger.sh" /usr/bin/dracut-pre-trigger
    inst_script "$moddir/dracut-pre-mount.sh" /usr/bin/dracut-pre-mount
    inst_script "$moddir/dracut-mount.sh" /usr/bin/dracut-mount
    inst_script "$moddir/dracut-pre-pivot.sh" /usr/bin/dracut-pre-pivot

    inst_script "$moddir/rootfs-generator.sh" "$systemdutildir"/system-generators/dracut-rootfs-generator

    inst_hook cmdline 00 "$moddir/parse-root.sh"
    if dracut_module_included initqueue; then
        # parse-root.sh injects grep call into initqueue/finished/devexists-${root_name}.sh
        inst grep
    fi

    for i in \
        dracut-cmdline.service \
        dracut-cmdline-ask.service \
        dracut-mount.service \
        dracut-pre-mount.service \
        dracut-pre-pivot.service \
        dracut-pre-trigger.service \
        dracut-pre-udev.service; do
        inst_simple "$moddir/${i}" "$systemdsystemunitdir/${i}"
        $SYSTEMCTL -q --root "$initdir" add-wants initrd.target "$i"
    done

    inst_simple "$moddir/dracut-tmpfiles.conf" "$tmpfilesdir/dracut-tmpfiles.conf"

    inst_multiple sulogin

    [ -e "${initdir}/usr/lib" ] || mkdir -m 0755 -p "${initdir}"/usr/lib

    local VERSION=""
    local PRETTY_NAME=""
    # Derive an os-release file from the host, if it exists
    if [[ -e "${dracutsysrootdir-}/etc/os-release" ]]; then
        # shellcheck disable=SC1090
        . "${dracutsysrootdir-}"/etc/os-release
        grep -hE -ve '^VERSION=' -ve '^PRETTY_NAME' "${dracutsysrootdir-}"/etc/os-release > "${initdir}"/usr/lib/initrd-release
        [[ -n ${VERSION} ]] && VERSION+=" "
        [[ -n ${PRETTY_NAME} ]] && PRETTY_NAME+=" "
    fi
    VERSION+="dracut-$DRACUT_VERSION"
    PRETTY_NAME+="dracut-$DRACUT_VERSION (Initramfs)"
    {
        echo "VERSION=\"$VERSION\""
        echo "PRETTY_NAME=\"$PRETTY_NAME\""
        # This addition is relatively new, intended to allow software
        # to easily detect the dracut version if need be without
        # having it mixed in with the real underlying OS version.
        echo "DRACUT_VERSION=\"${DRACUT_VERSION}\""
    } >> "$initdir"/usr/lib/initrd-release
    ln -sf ../usr/lib/initrd-release "$initdir"/etc/initrd-release
    ln -sf initrd-release "$initdir"/usr/lib/os-release
    ln -sf initrd-release "$initdir"/etc/os-release

}