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