]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | # This file is part of dracut. | |
3 | # SPDX-License-Identifier: GPL-2.0-or-later | |
4 | ||
5 | # Prerequisite check(s) for module. | |
6 | check() { | |
7 | # If the binary(s) requirements are not fulfilled the module can't be installed | |
8 | require_any_binary /usr/lib/bluetooth/bluetoothd /usr/libexec/bluetooth/bluetoothd || return 1 | |
9 | ||
10 | if [[ $hostonly ]]; then | |
11 | # Warn user if bluetooth kernel module is loaded | |
12 | # and if Peripheral (0x500) is found of minor class: | |
13 | # * Keyboard (0x40) | |
14 | # * Keyboard/pointing (0xC0) | |
15 | # and if Appearance is set to the value defined for keyboard (0x03C1) | |
16 | [ -d "/sys/class/bluetooth" ] && grep -qiE -e 'Class=0x[0-9a-f]{3}5[4c]0' -e 'Appearance=0x03c1' /var/lib/bluetooth/*/*/info 2> /dev/null \ | |
17 | && dwarn "If you need to use bluetooth, please include it explicitly." | |
18 | fi | |
19 | ||
20 | return 255 | |
21 | } | |
22 | ||
23 | # Module dependency requirements. | |
24 | depends() { | |
25 | # This module has external dependencies on the systemd and dbus modules. | |
26 | echo systemd dbus | |
27 | # Return 0 to include the dependent modules in the initramfs. | |
28 | return 0 | |
29 | } | |
30 | ||
31 | installkernel() { | |
32 | instmods bluetooth btrtl btintel btbcm bnep ath3k btusb rfcomm hidp | |
33 | inst_multiple -o \ | |
34 | /lib/firmware/ar3k/AthrBT* \ | |
35 | /lib/firmware/ar3k/ramps* \ | |
36 | /lib/firmware/ath3k-1.fw* \ | |
37 | /lib/firmware/BCM2033-MD.hex* \ | |
38 | /lib/firmware/bfubase.frm* \ | |
39 | /lib/firmware/BT3CPCC.bin* \ | |
40 | /lib/firmware/brcm/*.hcd* \ | |
41 | /lib/firmware/mediatek/mt7622pr2h.bin* \ | |
42 | /lib/firmware/qca/nvm* \ | |
43 | /lib/firmware/qca/crnv* \ | |
44 | /lib/firmware/qca/rampatch* \ | |
45 | /lib/firmware/qca/crbtfw* \ | |
46 | /lib/firmware/rtl_bt/* \ | |
47 | /lib/firmware/intel/ibt* \ | |
48 | /lib/firmware/ti-connectivity/TIInit_* \ | |
49 | /lib/firmware/nokia/bcmfw.bin* \ | |
50 | /lib/firmware/nokia/ti1273.bin* | |
51 | } | |
52 | ||
53 | # Install the required file(s) for the module in the initramfs. | |
54 | install() { | |
55 | # shellcheck disable=SC2064 | |
56 | trap "$(shopt -p globstar)" RETURN | |
57 | shopt -q -s globstar | |
58 | local -a var_lib_files | |
59 | ||
60 | inst_multiple -o \ | |
61 | "$dbussystem"/bluetooth.conf \ | |
62 | "$dbussystemservices"/org.bluez.service \ | |
63 | "${systemdsystemunitdir}/bluetooth.target" \ | |
64 | "${systemdsystemunitdir}/bluetooth.service" \ | |
65 | bluetoothctl | |
66 | ||
67 | inst_multiple -o \ | |
68 | /usr/libexec/bluetooth/bluetoothd \ | |
69 | /usr/lib/bluetooth/bluetoothd | |
70 | ||
71 | if [[ $hostonly ]]; then | |
72 | var_lib_files=("$dracutsysrootdir"/var/lib/bluetooth/**) | |
73 | ||
74 | inst_multiple -o \ | |
75 | /etc/bluetooth/main.conf \ | |
76 | "$dbussystemconfdir"/bluetooth.conf \ | |
77 | "$systemdsystemconfdir"/bluetooth.service \ | |
78 | "$systemdsystemconfdir/bluetooth.service.d/*.conf" \ | |
79 | "${var_lib_files[@]#"$dracutsysrootdir"}" | |
80 | fi | |
81 | ||
82 | inst_rules 69-btattach-bcm.rules 60-persistent-input.rules | |
83 | ||
84 | # shellcheck disable=SC1004 | |
85 | sed -i -e \ | |
86 | '/^\[Unit\]/aDefaultDependencies=no\ | |
87 | Conflicts=shutdown.target\ | |
88 | Before=shutdown.target\ | |
89 | After=dbus.service' \ | |
90 | "${initdir}/${systemdsystemunitdir}/bluetooth.service" | |
91 | ||
92 | $SYSTEMCTL -q --root "$initdir" enable bluetooth.service | |
93 | } |