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