0

With upstart, I used to have the permissions of some files set at boot time via a shell script in /etc/init.d/ (sym-linked, from /etc/rc2.d/):

link="/sys/class/backlight/intel_backlight"
chgrp backlight "$link/brightness"
chgrp backlight "$link/bl_power"
chmod 664 "$link/brightness"
chmod 664 "$link/bl_power"

But since Ubuntu 15.04, with systemd, I don't know how to do that.

Using systemd, which file(s) can be used to execute commands with root privileges at boot time ?

Thank you


Thanks to JdeBP, I found a way to have the permissions set for files that are generated at each boot. It uses tmpfiles.d, a component of systemd:

I created a file named backlight.conf (the .conf matters) in /etc/tmpfiles.d, containing these lines:

# Type Path                                       Mode UID  GID  Age Argument
f /sys/class/backlight/intel_backlight/brightness 0664 root backlight -
f /sys/class/backlight/intel_backlight/bl_power   0664 root backlight -

Now, the two files .../brightness and .../bl_power have the right groupship, and the right writing rights.

(This solves my problem, but doesn't answer my question)

loxaxs
  • 759
  • 5
  • 15

1 Answers1

-1

Perhaps by adding these lines into /etc/rc.local and sudo chmod a+x /etc/rc.local, which is the recommended action for init as well.

But I assume, that there should be better methods for controlling the backlight, e.g. here: Cannot change backlight brightness Ubuntu 14.04

naund
  • 1
  • It didn't work :(. Thank you anyway – loxaxs May 14 '15 at 12:32
  • It is definitely working. /etc/rc.local is executed during boot from systemd. But there should be a better method solving the backlight problem. – naund May 14 '15 at 13:19
  • Probably one of the configuration files of systemd allows to require the execution of some files, such as /etc/rc.local. – loxaxs May 14 '15 at 13:38