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