Ubuntu – rc.local not running on startup

bashbootscriptsstartup

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 &

Best Answer

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.

Related Question