]> git.ipfire.org Git - thirdparty/dracut.git/blame - modules.d/62bluetooth/module-setup.sh
fix(zfcp_rules): correct shellcheck regression when parsing ccw args
[thirdparty/dracut.git] / modules.d / 62bluetooth / module-setup.sh
CommitLineData
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.
6check() {
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
dfa408c9
LG
11 # Warn user if bluetooth kernel module is loaded
12 # and if Peripheral (0x500) is found of minor class:
97b86d37
HH
13 # * Keyboard (0x40)
14 # * Keyboard/pointing (0xC0)
8079ceaf 15 # and if Appearance is set to the value defined for keyboard (0x03C1)
dfa408c9 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 \
0ecb0388 17 && dwarn "If you need to use bluetooth, please include it explicitly."
97b86d37 18 fi
64ee2a53
AA
19
20 return 255
21}
22
23# Module dependency requirements.
24depends() {
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
31installkernel() {
32 instmods bluetooth btrtl btintel btbcm bnep ath3k btusb rfcomm hidp
33 inst_multiple -o \
09a1e5af 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*
64ee2a53
AA
51}
52
53# Install the required file(s) for the module in the initramfs.
54install() {
97b86d37 55 # shellcheck disable=SC2064
36aaa74f
PV
56 trap "$(shopt -p globstar)" RETURN
57 shopt -q -s globstar
97b86d37
HH
58 local -a var_lib_files
59
a38d9ec0 60 inst_multiple -o \
34b1dd2e 61 "$dbussystem"/bluetooth.conf \
e84d65c5 62 "$dbussystemservices"/org.bluez.service \
64ee2a53
AA
63 "${systemdsystemunitdir}/bluetooth.target" \
64 "${systemdsystemunitdir}/bluetooth.service" \
65 bluetoothctl
66
97b86d37
HH
67 inst_multiple -o \
68 /usr/libexec/bluetooth/bluetoothd \
69 /usr/lib/bluetooth/bluetoothd
70
64ee2a53 71 if [[ $hostonly ]]; then
97b86d37
HH
72 var_lib_files=("$dracutsysrootdir"/var/lib/bluetooth/**)
73
d03fb675 74 inst_multiple -o \
64ee2a53 75 /etc/bluetooth/main.conf \
34b1dd2e 76 "$dbussystemconfdir"/bluetooth.conf \
e84d65c5
AAF
77 "$systemdsystemconfdir"/bluetooth.service \
78 "$systemdsystemconfdir/bluetooth.service.d/*.conf" \
97b86d37 79 "${var_lib_files[@]#"$dracutsysrootdir"}"
64ee2a53
AA
80 fi
81
64ee2a53
AA
82 inst_rules 69-btattach-bcm.rules 60-persistent-input.rules
83
97b86d37 84 # shellcheck disable=SC1004
64ee2a53
AA
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}