2

My question is related to this question.

I would like to deactivate bluetooth on start up, unfortunately the proposed solution to add:

rfkill block bluetooth

to /etc/rc.local before exit 0 does not work on my Acer aspire 1810TZ running Ubuntu 13.10 with an Intel advanced wifilink N-6235.

Neither does the suggested solution for Thinkpad laptops.

What does work is to add:

/etc/init.d/bluetooth stop

to /etc/rc.local, but this disables the bluetooth applet, which I need to enable the bluetooth easily when I want to use bluetooth.

So the question is why doesn't rfkill block bluetooth work and how do I make it work again?

Thanks!

2
  • Can tell us if there is more stuff in /etc/rc.local except rfkill block bluetooth, exit and the comments?
    – MadMike
    Nov 5, 2013 at 16:11
  • There is one other command fstrim -v /, which trims my SSD.
    – Minos
    Nov 5, 2013 at 18:02

1 Answer 1

1

How to make /etc/rc.local work as expected

Since upstart starts its service asynchronously, it's pretty common that not all services are ready when /etc/rc.local is started. So you need to add sleep 3 (or another number, you need to find out yourself) at the beginning of you script.

You have to take care that the script isn't interrupted by a program that return's an error. Example: I can switch between two graphics-cards on my laptop (pre hybrid-graphicscard) and depending on which one is turned on I must use a different /sys/class/backlight/...-file to set its brightness. The easiest thing is to set both. But to ensure that the non-existing one doesn't interrupt the /etc/rc.local-script I append || true at the end of each command.

So this is how my rc.local-script looks right now (sans the comments at the beginning):

sleep 3

echo 2 > /sys/class/backlight/sony/brightness || true
echo 2 > /sys/class/backlight/nv_backlight/brightness || true
rfkill block bluetooth

exit 0
2
  • I tried adding sleep 3 and sleep 10 at the beginning of the script. Unfortunately this doesn't seem to have any effect, bluetooth is still on on boot. How can I discover if the script is being interrupted?
    – Minos
    Nov 18, 2013 at 15:14
  • Try it with a higher number first. Like sleep 10 or sleep 15. You could add echo "sleep called in /etc/rc.local" >> /var/rc.local.log, but I don't have access to a Linux computer right now and can't even syntax check that line.
    – MadMike
    Nov 18, 2013 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .