6

I have created a script to enable my Bluetooth driver. I then used rc.local to run it from startup. But, this is not working.

When running the command systemctl status rc-local.service I get:

Failed to issue method call: no such interface 'org.freedesktop.DBus.Properties' 
 on object at path /org/freedesktop/systemd1/unit/rc_2dlocal_2eservice

What I should get is something that looks like this:

rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled) 
Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (running) since Mon 2018-04-02 10:39:44 -03; 1s ago
  Process: 2044 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
 Main PID: 2049 (svscanboot)
Tasks: 3
 Memory: 556.0K
CPU: 10ms
CGroup: /system.slice/rc-local.service

All of my files are executable (chmod 755 [filename]), and I verified that the rc.local should run with sudo /etc/init.d/rc.local start and sudo /etc/rc.local start.

Is there anything I am missing?

Current rc.local file:

#!/bin/sh -e
#
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/[redacted]/Desktop/rtl8723bs_bt/start_bt.sh

exit 0

Contents from the start_bt.sh

#!/bin/bash
#
# Shell script to install Bluetooth firmware and attach BT part of
# RTL8723BS
#
if [ "$1" = "" ]
then
    # Find the TTY attached to the BT device
    TTYSTRING=`dmesg -t | grep tty | grep MMIO | cut -b 14-18`
    TTY=`expr substr "$TTYSTRING" 1 5`

    if [ "$TTYSTRING" = "" ]
    then
    echo
    echo "No BT TTY device has been found"
    echo "Either this computer has no BT device that uses hciattach, or"
    echo "Your kernel does not have module 8250_dw configured."
    echo "Note: The configuration variable is CONFIG_SERIAL_8250_DW."
    echo
    exit 1
    fi
else
    # Use the TTY device mentioned oi the call
    TTY=$1
fi

TTY="/dev/$TTY"
echo "Using device $TTY for Bluetooth"

if [ ! -f /lib/firmware/rtl_bt/rtlbt_config ];
then
    mkdir -p /lib/firmware/rtl_bt/
    cp rtlbt_* /lib/firmware/rtl_bt/.
fi
./rtk_hciattach -n -s 115200 $TTY rtk_h5 > hciattach.txt 2>&1 &
9
  • Does systemctl status rc-local.service provides active (running) when your script isn't there? – pa4080 Mar 26 '19 at 6:23
  • Show what's in your rc.local... Does it have a proper shebang, and ends with "exit 0"? – wazoox Mar 26 '19 at 19:02
  • @wazoox Added. I have verified that the rc.local file works using the highlighted commands – Cutwow475 Mar 27 '19 at 1:48
  • 1
    Two ideas - 1 - for the start_bt.sh script: try to provide full path, for rtlbt_* and ./rtk_hciattach -n -s 115200 $TTY rtk_h5 > hciattach.txt 2>&1 & - 2 - Move the start_bt.sh script to somewhere like /opt with root as owner. – cmak.fr Mar 28 '19 at 17:27
  • 1
    Yes obviously the "start_bt" script copy files around and run commands from a defined place which isn't / (from which /etc/rc.local is ran). You should probably add a line like this : cd /home/[redacted]/Desktop/rtl8723bs_bt/ right after the line echo "Using device $TTY for Bluetooth" – wazoox Mar 28 '19 at 18:14
2

According to This forum post the problem could be with failed distro-upgrades. After converting my physical disk to a VM and updating it there it worked with a test script: test.sh

echo run > run.txt

I then put back in my original script and it still didn't work. Taking the advice of Wazoox:

Yes obviously the "start_bt" script copy files around and run commands from a defined place which isn't / (from which /etc/rc.local is run). You should probably add a line like this : cd /home/[redacted]/Desktop/rtl8723bs_bt/ right after the line echo "Using device $TTY for Bluetooth"

By adding cd /home/[redacted]/Desktop/rtl8723bs_bt/ to the script fixed the problem of it not running. To fix this problem on the physical computer I will need to reinstall Ubuntu, which wasn't a problem for me.

1
+50

I rewrite my comment as an answer:

The "start_bt" script copy files around and run commands from a defined place which isn't / (from which /etc/rc.local is ran). You should add a line like this :

cd /home/[redacted]/Desktop/rtl8723bs_bt/

right after the line

echo "Using device $TTY for Bluetooth" 

So that all the commands are ran in the right folder.

1
  • 1
    Thank you for all of the help. This fix seems so obvious now that you pointed it out. – Cutwow475 Mar 29 '19 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.