3

I need to apply a patch ram to a chip for Bluetooth on startup of a Debian linux. This patch uses /dev/mem to reset the GPIO. This updated init script for bluetooth is included in /etc/init.d/bluetooth.

My bluetooth.service is

[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)

[Service]
Type=dbus
BusName=org.bluez
ExecStart=/etc/init.d/bluetooth start
User=root
NotifyAccess=main

[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service

However, when I reboot, I get an error saying `Unable to open /dev/mem: Operation not permitted"

I understand that /dev/mem is only accessible to root, but aren't I running my init script as root?

Kousha
  • 32,871
  • 51
  • 172
  • 296

1 Answers1

-4

It clearly says that you don't have permission to run a script, you can you need to run the script as root user as ExecStart=/etc/init.d/bluetooth start this command should be run as root user

just login as root and re-run the script

Running the script when system startup

  1. Create a script called bluetooth.service in /etc/init.d/ directory(login as root) vi /etc/init.d/bluetooth.service

  2. Setup executable permission on script: chmod +x /etc/init.d/bluetooth.service

  3. Make sure this script get executed every time Debian Linux system boot up/comes up:

    update-rc.d bluetooth.service defaults 100

Where, bluetooth.service: is Your startup script name defaults : The argument 'defaults' refers to the default runlevels, which are 2 through 5. 100 : Number 100 means script will get executed before any script containing number 101. Just run the command

ls –l /etc/rc3.d/

This command will soft linked to /etc/init.d with numbers.

Next time you reboot the system, you custom command or script will get executed via bluetooth.services. Y

  1. Execute shell script at system startup Open the file bluetooth.service in /etc/init.d/ directory
Community
  • 1
  • 1
shining
  • 1,049
  • 16
  • 31
  • 1
    I understand what the problem is. This is an init script. I don't want to manually run this script. I want it to run atomically when the system boots up. – Kousha Jul 07 '15 at 01:31
  • I have added details about the system start up – shining Jul 07 '15 at 01:42
  • I'll test this later tomorrow. With `systemctl` I thought you include the service inside `/lib/systemd/system/` and then have the `ExecStatr` link to whatever file you want. What you have provided seems like a SysVInit method – Kousha Jul 07 '15 at 05:33
  • If you want the service to be started on boot up, you need to run `sudo systemctl enable bluetooth.service` – Thirupathi Thangavel Jul 29 '15 at 13:51