How can I replicate `fortune > /etc/motd` with systemd/tmpfiles.d?

1291
Pedro Silva

None of the action types described in tmpfiles.d(5) seems to allow for running a command as part of creating a temporary file. It is possible to write an argument to a file, for example with action 'w', but not run fortune > /etc/motd.

Since the recommended way to generate tmp files in Arch Linux is tmpfiles.d, I figure there's a way to do it without resorting to systemd/rc.local hacks.

0

1 ответ на вопрос

1
grawity

Create a normal .service unit and make it run on boot.

[Service] Type=oneshot ExecStart=/bin/sh -c "fortune > /etc/motd" 

There is no special method for that; writing dynamic contents into a config file is out of scope for tmpfiles.d.