systemd: fails to run service: error failed to get dbus name
My shell script runs fine manually, but causes an error when started by systemd. What is the problem?
I have configured xboxdrv to remap my logitech f310 controller as a mouse on my Raspberry Pi 3B running Buster.
When I run it from the command line as
sudo xboxdrv -D -c /usr/share/doc/xboxdrv/logitech.xboxdrv
It works fine. So I set it up as a service to run at boot. First I put the above into a shell script:
#!/bin/bash
sudo xboxdrv -D -c /usr/share/doc/xboxdrv/logitech.xboxdrv --silent & sleep 1
Which I then saved as /usr/share/doc/xboxdrv/logitech.sh and then made executable.
When I run that script with sudo /usr/share/doc/xboxdrv/logitech.sh
everything works. So far so good.
Then I make a service file:
[Unit]
Description=start xboxdrv to configure logitech f310 gamepad
After=default.target
[Service]
ExecStart=/usr/share/doc/xboxdrv/logitech.sh
[Install]
WantedBy=default.target
I enable this:
sudo systemctl enable /etc/sysemd/system/xboxdrv.service
and start it:
sudo systemctl start xboxdrv.service
But now I get an error. This is what I get from journalctl -xe:
[ERROR] XboxdrvDaemon::run(): fatal exception: failed to get unique dbus name:
Connection ":1.21" is not allowed to own the service "org.seul.Xboxdrv" due to
security policies in the configuration file
So what does this mean and why am I getting it? I have no idea why xboxdrv needs this connection? What configuration file is it talking about?
And, more to the point, how do I fix this?
Thanks!
It looks like this is a known issue with permissions which can be fixed by editing or writing a new dbus configuration (which should be the configuration file that is mentioned).