dbus dependency to start bluetooth
Easy 2.2.9 and 2.2.9.1 has faster startup, due to parallel processing of kernel uevents by udevd, see here:
https://bkhome.org/news/202002/a-twisted-tale-of-bluetoothd-failing.html
Unfortunately, those above versions of Easy have not managed to start
the bluetooth daemon before the udev daemon has started. So bluetooth
does not work, not always anyway.
The dependency needed to be solved properly. Easy has pup_event service management to do this. You can find documentation in /usr/local/pup_event.
I inserted "dbus" as a dependency in /etc/eventmanager:
PE_SERVICE_MANAGER='network%cups-net-fixONESHOT:qsyncONESHOT:dnsmasq:ec-net bluetoothhw:dbus%bluetooth:bluealsa'
...now, /etc/init.d/bluetooth and /etc/init.d/bluealsa will launch
after both dependencies 'bluetoothhw' and 'dbus' are met. The former is
met if there is bluetooth hardware, either at bootup or later in the
case of a bluetooth dongle getting plugged in. The latter, 'dbus', is
met when the 'dbusd' daemon is running.
/etc/rc.d/rc.services_ipc has this code:
for aDEP in $DEPs
do
MSG1=''
[ ! "$aDEP" ] && continue #200213 precaution.
#200213 detect if dep already avail...
[ -s /tmp/pup_event_backend/${aDEP}_ ] && MSG1="$(cat /tmp/pup_event_backend/${aDEP}_)"
[ ! "$MSG1" ] && MSG1="$(/usr/local/pup_event/pup_event_ipc "${aDEP}:${$}")" #***WAIT FOR FILE CHG***
#...ex: network:12345 MSG1=eth0 or MSG1='' (empty, meaning i/f gone down)
[ ! "$MSG1" ] && continue 2
if [ "$aDEP" == "x" ];then #180301
DISPLAY=":$(grep -o '[01]' /tmp/pup_event_backend/x_)"
export DISPLAY #ex: :0
fi
done
...in this case, $DEPs is "bluetoothhw dbus". 'pup_event_ipc' will
wait until files /tmp/pup_event_ipc/bluetoothhw_<pid> and
/tmp/pup_event_ipc/dbus_<pid> are written to, and if both
non-empty content, the dependencies will be met.
EDIT 2020-02-13:
The green code above is a bug fix, slightly different from the original blog post.
I posted earlier how bluetooth hardware is detected, and /tmp/pup_event_ipc/bluetoothhw_<pid> gets written to.
For dbus, it is a simple matter of writing to
/tmp/pup_event_ipc/dbus_<pid> after /etc/init.d/messagebus has
run. This is handled in /etc/rc.d/rc.services:
#200212 see /etc/eventmanager...which causes 'pup_event_ipc' in rc.services to exit, assigning "started" to MSG1.
if [ "${baseSC}" == "messagebus" ];then
echo -n "started" > /tmp/pup_event_backend/dbus_ #permanent flag (see rc.services_ipc).
for aSC in /tmp/pup_event_ipc/dbus_* #rc.services_ipc should have already created this.
do
[ "$aSC" == "" ] && continue
[ ! -f $aSC ] && continue #200212b if no match for glob, ash uses literal filename.
echo -n "started" > ${aSC}
done
fi
It is quite simple, when you get the hang of it. This is "proper" dependency management for bluetooth, and I have built Easy 2.2.10 and confirmed it works.
Tags: easy