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 &
CootMoon
  • 133
  • Does systemctl status rc-local.service provides active (running) when your script isn't there? – pa4080 Mar 26 '19 at 06: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 – CootMoon Mar 27 '19 at 01:48
  • Aren't you trying to run a program with a graphic component from rc.local? What's in "Blue.sh' ? – wazoox Mar 27 '19 at 16:58
  • @wazoox sorry. I wasn't home when I put in the rc.local file. I fixed the path of the script and I added the script. And I am not trying to run a program with a GUI, just a script. – CootMoon Mar 27 '19 at 22:05
  • 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
  • @wazoox that fixed it on my VM at least (which is a copy of the physical disc). But I think I found my real problem. Failed distro-upgrades, that could be giving me the error. With some more research, I found that this was a very likely cause of this problem. – CootMoon Mar 28 '19 at 19:55
  • @wazoox I would like to award you the bounty so if you could copy my answer or write your own I would be able to give the bounty. – CootMoon Mar 28 '19 at 20:03

2 Answers2

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.

CootMoon
  • 133
1

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.

wazoox
  • 256
  • 2
  • 7