1

After following this guide here on my Raspberry Pi 3: http://www.instructables.com/id/Turn-your-Raspberry-Pi-into-a-Portable-Bluetooth-A/?ALLSTEPS (Step 6)

I came across an error which says update-rc.d: error: insserv rejected the script header when running sudo update-rc.d bluetooth-agent defaults.

This is what my bluetooth agent file looks like. Are my headers being applied incorrectly?

#!/bin/sh -e
#/etc/init.d/bluetooth-agent
### BEGIN INIT INFO
# Provides: bluetooth-agent
# Required-Start: $remote_fs $syslog bluetooth pulseaudio
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Makes Bluetooth discoverable and connectable to 0000
### END INIT INFO

USER=root
HOME=/root
export USER HOME
case "$1" in
start)
echo "setting bluetooth discoverable"
sudo hciconfig hci0 piscan
start-stop-daemon -S -x /usr/bin/bluetooth-agent -c pi -b -- 0000
echo "bluetooth-agent startet pw: 0000"
;;
stop)
echo "Stopping bluetooth-agent"
start-stop-daemon -K -x /usr/bin/bluetooth-agent
;;
*)
echo "Usage: /etc/init.d/bluetooth-agent {start|stop}"
exit 1
;;
esac
exit 0
Oliver Kuchies
  • 235
  • 1
  • 4
  • 13

2 Answers2

1

That instructable is for Raspbian Wheezy, your Raspberry Pi 3 is most likely running Raspbian Jessie (RPi3 does't run on Wheezy). The major difference between the two is Wheezy was using System V (which used update-rc.d), while Jessie is using systemd instead (which is not using update-rc.d). Either remove systemd and replace it with System V, or see how to perform the same task using systemd.

tlhIngan
  • 3,372
  • 5
  • 19
  • 33
  • Systemd is backward compatible with this kind of script and you will find there is a little stack of them still used on the latest version of Raspbian. That said, I agree if you are going to start learning how to implement an init service you might as well start learning the new way rather than the old one. – goldilocks Oct 31 '16 at 13:33
1

Here is the simple solution:

# Required-Start: $remote_fs $syslog bluetooth pulseaudio

has the wrong format - there are no "$"'s in front of bluetooth and pulseaudio. So the correct line would be

# Required-Start: $remote_fs $syslog $bluetooth $pulseaudio

As mentioned in the answers init.d scripts are deprecated nowadays - systemd will at some point drop the init.d compatibility.

The best solution would contain a systemd service unit file and unit activation that fully replaces the above init.d script. So anyone: please don't argue about deprecation, give that answer here if you know it. Until then: the simple solution works for now, I just tested it.

guz4217
  • 11
  • 1