summaryrefslogtreecommitdiffstats
path: root/modules.d/95udev-rules/module-setup.sh
blob: e5b7f97f0fc88ac69486fb44da7e71dd03c225e2 (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
70
71
72
73
74
75
76
77
78
79
#!/bin/bash

# called by dracut
install() {
    local _i

    # Fixme: would be nice if we didn't have to guess, which rules to grab....
    # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
    # of the rules we want so that we just copy those in would be best
    inst_multiple udevadm cat uname blkid

    [[ -d ${initdir}/$systemdutildir ]] || mkdir -p "${initdir}/$systemdutildir"
    for _i in "${systemdutildir}"/systemd-udevd "${udevdir}"/udevd /sbin/udevd; do
        [[ -x $dracutsysrootdir$_i ]] || continue
        inst "$_i"

        if ! [[ -f ${initdir}${systemdutildir}/systemd-udevd ]]; then
            ln -fs "$_i" "${initdir}${systemdutildir}"/systemd-udevd
        fi
        break
    done
    if ! [[ -e ${initdir}${systemdutildir}/systemd-udevd ]]; then
        derror "Cannot find [systemd-]udevd binary!"
        exit 1
    fi

    inst_rules \
        50-udev-default.rules \
        55-scsi-sg3_id.rules \
        58-scsi-sg3_symlink.rules \
        59-scsi-sg3_utils.rules \
        60-block.rules \
        60-cdrom_id.rules \
        60-persistent-storage.rules \
        64-btrfs.rules \
        70-uaccess.rules \
        71-seat.rules \
        73-seat-late.rules \
        75-net-description.rules \
        80-drivers.rules 95-udev-late.rules \
        80-net-name-slot.rules 80-net-setup-link.rules \
        "$moddir/59-persistent-storage.rules" \
        "$moddir/61-persistent-storage.rules"

    {
        for i in cdrom tape dialout floppy; do
            if ! grep -q "^$i:" "$initdir"/etc/group 2> /dev/null; then
                if ! grep "^$i:" "$dracutsysrootdir"/etc/group 2> /dev/null; then
                    case $i in
                        cdrom) echo "$i:x:11:" ;;
                        dialout) echo "$i:x:18:" ;;
                        floppy) echo "$i:x:19:" ;;
                        tape) echo "$i:x:33:" ;;
                    esac
                fi
            fi
        done
    } >> "$initdir/etc/group"

    inst_multiple -o \
        "${udevdir}"/ata_id \
        "${udevdir}"/cdrom_id \
        "${udevdir}"/create_floppy_devices \
        "${udevdir}"/fw_unit_symlinks.sh \
        "${udevdir}"/hid2hci \
        "${udevdir}"/path_id \
        "${udevdir}"/input_id \
        "${udevdir}"/scsi_id \
        "${udevdir}"/usb_id

    inst_libdir_file "libnss_files*"

    # Install the hosts local user configurations if enabled.
    if [[ $hostonly ]]; then
        inst_dir /etc/udev
        inst_multiple -H -o \
            /etc/udev/udev.conf
    fi
}