FS#31890 - [lirc-utils] Systemd 'lirc.service' does not read /etc/conf.d/lircd.conf

Attached to Project: Arch Linux
Opened by Paolo (palmaway) - Thursday, 11 October 2012, 00:13 GMT
Last edited by Tobias Powalowski (tpowa) - Tuesday, 08 October 2013, 14:53 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Tobias Powalowski (tpowa)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 23
Private No

Details

Before the switch to systemd, the /etc/rc.d/lirc.d daemon script would read the file /etc/conf.d/lircd.conf in order to get custom options. In particular, this is used to configure the device LIRC should listen to, and set the driver (most commonly, to 'devinput'). The provided systemd 'lirc.service' does not read these options anymore. Since LIRC does not have a configuration file for these settings (files in /etc/lirc/ are used for other purposes), it is impossible to configure most systems, since the default device /dev/lirc0 is usually not available under Arch.

Additional info:
* package version:
1:0.9.0-30
* config files:
/etc/conf.d/lircd.conf which contains arguments that need to be passed to lircd

Steps to reproduce:
- configure some options in /etc/conf.d/lircd.conf
- restart the daemon with:
# systemctl restart lirc.service
- the options are not passed to the daemon

Possible solution:
I overwrote the service file with my own in /etc/systemd/system (see below), and this partially solves the problem. However, this oviously does not work when variables in /etc/conf.d/lircd.conf are not set, so a general solution like the one implemented by the /etc/rc.d/lirc.d script is needed.

Output of systemd-delta:

[OVERRIDDEN] /etc/systemd/system/lirc.service → /usr/lib/systemd/system/lirc.se

--- /usr/lib/systemd/system/lirc.service 2012-10-06 12:32:07.000000000 +
+++ /etc/systemd/system/lirc.service 2012-10-11 01:51:08.334578131 +0200
@@ -2,8 +2,9 @@
Description=Linux Infrared Remote Control

[Service]
+EnvironmentFile=/etc/conf.d/lircd.conf
ExecStartPre=/usr/bin/ln -sf /run/lirc/lircd /dev/lircd
-ExecStart=/usr/sbin/lircd --pidfile=/run/lirc/lircd.pid
+ExecStart=/usr/sbin/lircd --pidfile=/run/lirc/lircd.pid --device=${LIRC_DEVICE} --driver=${LIRC_DRIVER}
Type=forking
PIDFile=/run/lirc/lircd.pid
This task depends upon

Closed by  Tobias Powalowski (tpowa)
Tuesday, 08 October 2013, 14:53 GMT
Reason for closing:  Not a bug
Comment by Aaron Barany (akb825) - Sunday, 21 October 2012, 22:30 GMT
I needed to apply this change to be able to use my remote at all. By default, lircd listens to device /dev/lirc. However, at least with my mceusb device, it creates the socket /dev/lirc0, which means that when lircd is started it is reading from the wrong socket.

In order for this change to work, /etc/conf.d/lircd.conf will need to be modified so LIRC_DRIVER="default". Otherwise, lircd will exit with an error, stating that the driver '' isn't supported. Assuming the change to lirc.service is made to the installed files, the change to lirc.conf will also need to be made in order to prevent the default installation from failing.
Comment by Dave Reisner (falconindy) - Sunday, 21 October 2012, 22:38 GMT
It would be far better to fine sane defaults for the service and let users override in /etc as needed. EnvironmentFiles are ugly and should be avoided whenever possible.
Comment by Paolo (palmaway) - Sunday, 21 October 2012, 22:53 GMT
Dave, I disagree. EnvironmentFiles might be ugly, but they don't leave you with a non-working configuration when something changes in the packet/software. I had to overwrite in /etc, but this means that if the configuration of the LIRC packet will be updated, the change will not be replicated in my system (thanks to the override). Which, in turn, means that LIRC might stop working after an upgrade, without any notification or warning.
Comment by Aaron Barany (akb825) - Sunday, 21 October 2012, 23:06 GMT
Speaking of sane defaults, I still have to have this line in my rc.local file: echo lirc > /sys/class/rc/rc0/protocols. Otherwise it tries to treat the remote as a keyboard and it won't work correctly with lircd. If there was a way to roll this into either lircd.conf or have it be automatic in lirc.service that would be much better.

I opened a bug about it over a year ago (https://bugs.archlinux.org/task/23673) but nothing came of it.
Comment by ctxfi-user (ctxfi-user) - Wednesday, 24 October 2012, 19:28 GMT
This is a kick in my ass to abandon the somewhat deprecated lircd...

@Aaron: Install v4l-utils and understand what /usr/lib/udev/rules.d/70-infrared.rules does. Try your own rule for your purpose in /etc/udev/rules.d (ir-keytable --protocol=LIRC) or try to adjust /etc/rc_maps.cfg to force the lirc protocol (if the latter is even possible, I'm not sure). Keeping RC6 protocol should be the better solution. If you rely on a LIRC daemon use RC6 protocol and start lircd using devinput driver, the appropriate rc device node in /dev/input/by-path/... and the key table /usr/share/lirc/remotes/devinput/lircd.conf.devinput.

Edit: +1 for fine sane defaults for the service
Comment by Michael (SiD) - Thursday, 01 November 2012, 15:45 GMT
I use this service file (found in the wiki I think). Saved it as /etc/systemd/system/lircd.service


[Unit]
Description=LIRC Daemon
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/lircd.conf
PIDFile=/run/lirc/lircd.pid
ExecStartPre=/bin/mkdir -p /run/lirc
ExecStartPre=/bin/rm -f /dev/lircd
ExecStartPre=/bin/rm -f /run/lirc/lircd
ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd

ExecStart=/usr/sbin/lircd -d $LIRC_DEVICE -P /run/lirc/lircd.pid -H $LIRC_DRIVER $LIRC_CONFIGFILE
ExecStopPost=/bin/rm -f /dev/lircd
ExecStopPost=/bin/rm -fR /run/lirc

[Install]
WantedBy=multi-user.target


no need to override the service file from lirc-utils package, just don't enable lirc.service, instead enable lircd.service.

Comment by Greg (dolby) - Thursday, 01 November 2012, 15:58 GMT
See  FS#32354   FS#32336  and  FS#32275  . Systemd wont work with /etc/conf.d.
Comment by Balló György (City-busz) - Thursday, 01 November 2012, 18:38 GMT
I think that EnvironmentFile is really required in this case. As it described in the wiki[1]:

"Not using an EnvironmentFile= is OK if:"

1. "Either the daemon has its own configuration file where the same settings can be specified"

-> lircd has NOT own a configuration file, these settings cannot be specified elsewhere.

2. "The default service file "just works" in the most common case. Users who want to change the behavior should then override the default service file. If it is not possible to provide a sane default service file, it should be discussed on a case-by-case basis"

-> The lirc.service file does NOT work in the most common case, because most users have to set the device file and driver for lircd. lircd is unable to detect the proper configuration without specifying it with command line parameters.


[1] https://wiki.archlinux.org/index.php/DeveloperWiki:Systemd#Units
Comment by Rasmus Edgar (ashren) - Sunday, 11 November 2012, 00:35 GMT
The following additions to lirc.service solved my lircd with systemd issues:

diff /etc/systemd/system/lirc.service /usr/lib/systemd/system/lirc.service
5,6d4
< EnvironmentFile=/etc/conf.d/lircd.conf
< ExecStartPre=/usr/bin/ln -sf /dev/lirc0 /dev/lirc
Comment by Manuel Reimer (M-Reimer) - Thursday, 17 January 2013, 01:10 GMT
  • Field changed: Percent Complete (100% → 0%)
The problem discussed here, is still *not* fixed! It is impossible to add a "--device" paramter to the lircd, started by systemd, without hacking manually in the .service file. Without a "--device" parameter, lircd starts up in a nonfunctional and useless state. The service file needs fixing to allow to configure such parameters.
Comment by Kim Silkebækken (Lokaltog) - Thursday, 14 March 2013, 08:27 GMT
I can confirm that this requires a `--device` parameter. My IR receiver is located at `/dev/ttyUSB0`, so the symlinking in the current service file makes no sense and doesn't help at all for "non-standard" configurations.
Comment by Bruand Frédéric (fredolido) - Sunday, 28 April 2013, 10:52 GMT
Good idea to change /usr/lib/systemd/system/lirc.service because all update change the file to the default.
In the same idea, the /usr/lib/systemd/system/irexec.service must change like this
- ExecStart=/usr/bin/irexec --daemon
+ ExecStart=/usr/bin/irexec --daemon /etc/lirc/irexec.conf
this is a idea to have a global config to execute script with IR remote
Comment by Tobias Powalowski (tpowa) - Tuesday, 08 October 2013, 14:18 GMT
Please test lirc package from [testing] 1:0.9.0-63.
Comment by Christopher Reimer (CReimer) - Tuesday, 08 October 2013, 14:40 GMT
No difference. We need EnvironmentFile support in lirc.service
Comment by Dave Reisner (falconindy) - Tuesday, 08 October 2013, 14:52 GMT
We really don't. This is fine with dropin support.

Create "/etc/systemd/system/lirc.service.d/device.conf" (filename doesn't matter aside from the .conf suffix)

Add:

[Service]
ExecStart=
ExecStart=/usr/bin/lircd --whatever --goaway

Loading...