You are not logged in.

#1 2013-03-30 12:05:37

Ovion
Member
Registered: 2013-02-24
Posts: 78

/etc/tmpfiles.d or own service file?

Hi,
I recently learned about the possibilities of /etc/tmpfiles.d of systemd and because I have to set some values in /sys/somewhere on bootup I wondered whether better to do that via /etc/tmpfiles.d or in an own service file (a oneshot which I have, anyway, because I have to execute a bashscript on bootup, so I could add setting the values without further problems).

Would you recommend to use /etc/tmpfiles.d or an own service-file and why? I'm trying to figure out in which situations better to use /etc/tmpfiles.d and in which better to write a service file.

Thanks in advance!

Offline

#2 2013-03-30 13:07:21

progandy
Member
Registered: 2012-05-17
Posts: 2,146

Re: /etc/tmpfiles.d or own service file?

tmpfiles.d is preferred if it works, but with paths in /sys problems can occur (tmpfiles service is called before path is available)

Offline

#3 2013-03-30 19:43:33

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: /etc/tmpfiles.d or own service file?

Yes, I think you should probably be more specific about what it is you are actually trying to accomplish.

For example, I tried using tmpfiles.d to set my screen brightness.  It worked for a bit, and then I noticed that it was inconsistent.  It worked more often than not, but not every time.  So I ended up using a udev rule to set teh value as soon as the appropriate "brightness" file in /sys was made available.

Offline

#4 2013-03-31 19:39:59

Ovion
Member
Registered: 2013-02-24
Posts: 78

Re: /etc/tmpfiles.d or own service file?

I want to set the sensitivity and speed of my trackpoint as well as the possibility to simulate a leftclick when tapping on it.
What I want to do exactely is:

cd /sys/devices/platform/i8024/serio1/serio2
echo -n 120 > speed
echo -n 250 > sensitivity
echo -n 1 > press_to_select

(in the service-file I do it without the cd-command, of course).

I sometimes noticed it not working in the unit-file, so I added an "After="-option to the service file. The same can happen concerning /sys using tmpfiles.d, so in my case, the unit-file should be preferred?

But /run is definitely available at the time of execution of tmpfiles.d? Is there a special reason for /sys not being available then sometimes? (The sometimes is of course explainable by systemd's parallelisation)

Offline

#5 2013-03-31 19:43:38

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: /etc/tmpfiles.d or own service file?

This is a situation in which a tmpfile will probably not work since these directories are really not created until X starts.  So if you are manually starting X with startx, the necessary directories will not be present when systemd-tmpfiles runs.

In a service file, it is not a shell.  So you either need to do "ExecStart=/bin/bash -c "echo -n 120 > /sys/devices/platform/i8124/serio1/serio2/speed" or you need to make a small script that does these things and then call that.  I would make the script instead of calling three separate shells to perform these commands.


Edit: The reason why this is not there when it is called is because this functionality is not in use before a graphical interface is brought up and X is set up.  I had a udev rule to do this, but it only worked if I had my system to bring up X right away (by booting into the graphical.target for which I don't use a display manager).

Last edited by WonderWoofy (2013-03-31 19:47:11)

Offline

#6 2013-04-09 11:00:34

Ovion
Member
Registered: 2013-02-24
Posts: 78

Re: /etc/tmpfiles.d or own service file?

Ok, thanks. I will then stick to the service-file, if I find a way to bind its execution to the starting of X (because I use startx for starting the graphical environement), otherwise I have to look for another possibility to execute root-commands on X-start.

Offline

Board footer

Powered by FluxBB