]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/62bluetooth/module-setup.sh
fix: shellcheck 0.7.2
[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 # 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
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 \
31 /usr/lib/firmware/ar3k/AthrBT* \
32 /usr/lib/firmware/ar3k/ramps* \
33 /usr/lib/firmware/ath3k-1.fw \
34 /usr/lib/firmware/BCM2033-MD.hex \
35 /usr/lib/firmware/bfubase.frm \
36 /usr/lib/firmware/BT3CPCC.bin \
37 /usr/lib/firmware/brcm/*.hcd \
38 /usr/lib/firmware/mediatek/mt7622pr2h.bin \
39 /usr/lib/firmware/qca/nvm* \
40 /usr/lib/firmware/qca/crnv* \
41 /usr/lib/firmware/qca/rampatch* \
42 /usr/lib/firmware/qca/crbtfw* \
43 /usr/lib/firmware/rtl_bt/* \
44 /usr/lib/firmware/intel/ibt* \
45 /usr/lib/firmware/ti-connectivity/TIInit_* \
46 /usr/lib/firmware/nokia/bcmfw.bin \
47 /usr/lib/firmware/nokia/ti1273.bin
48
49 }
50
51 # Install the required file(s) for the module in the initramfs.
52 install() {
53 # shellcheck disable=SC2064
54 trap "$(shopt -p nullglob globstar)" RETURN
55 shopt -q -s nullglob globstar
56 local -a var_lib_files
57
58 inst_multiple \
59 "${systemdsystemunitdir}/bluetooth.target" \
60 "${systemdsystemunitdir}/bluetooth.service" \
61 bluetoothctl
62
63 inst_multiple -o \
64 /usr/libexec/bluetooth/bluetoothd \
65 /usr/lib/bluetooth/bluetoothd
66
67 if [[ $hostonly ]]; then
68 var_lib_files=("$dracutsysrootdir"/var/lib/bluetooth/**)
69
70 inst_multiple \
71 /etc/bluetooth/main.conf \
72 /etc/dbus-1/system.d/bluetooth.conf \
73 "${var_lib_files[@]#"$dracutsysrootdir"}"
74 fi
75
76 inst_rules 69-btattach-bcm.rules 60-persistent-input.rules
77
78 # shellcheck disable=SC1004
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 }