我创建了一个脚本来启用我的蓝牙驱动程序。然后我使用 rc.local 从启动时运行它。但是,这不起作用。
运行命令时systemctl status rc-local.service
我得到:
Failed to issue method call: no such interface 'org.freedesktop.DBus.Properties'
on object at path /org/freedesktop/systemd1/unit/rc_2dlocal_2eservice
我应该得到的东西看起来像这样:
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
我的所有文件都是可执行的(
chmod 755 [filename]
),并且我已验证 rc.local 应该使用sudo /etc/init.d/rc.local start
和运行sudo /etc/rc.local start
。
我是否遗漏了什么?
当前 rc.local 文件:
#!/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
内容来自启动
#!/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 &
答案1
根据此论坛帖子问题可能出在发行版升级失败。将我的物理磁盘转换为虚拟机并在那里更新后,它可以使用测试脚本:test.sh
echo run > run.txt
然后我将其放回原来的脚本,但仍然不起作用。听取建议瓦佐克斯:
是的,显然“start_bt”脚本会复制文件并从定义的位置(不是 / 的位置)运行命令(/etc/rc.local 就是从这里运行的)。您可能应该在 echo “使用设备 $TTY 进行蓝牙”行后添加一行这样的命令:cd /home/[redacted]/Desktop/rtl8723bs_bt/
通过将 cd /home/[redacted]/Desktop/rtl8723bs_bt/ 添加到脚本中,解决了无法运行的问题。要在物理计算机上解决此问题,我需要重新安装 Ubuntu,但这对我来说不是问题。
答案2
我重写我的评论作为答案:
“start_bt”脚本会复制文件并从定义的位置(不是 / 的位置)运行命令(/etc/rc.local 就是从这里运行的)。您应该添加如下一行:
cd /home/[redacted]/Desktop/rtl8723bs_bt/
紧接着
echo "Using device $TTY for Bluetooth"
这样所有命令都在正确的文件夹中运行。